使用anchor=W的Python tkinter文本显示GUI

2024-05-03 12:57:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用anchor=W将所有文本对齐在一行中,但无法这样做。在

GUI脚本

{1美元^

我想用单个行显示,例如: 我还想在开始时显示枚举,试过它不起作用。在

1.U1a1400     3C      CAN Initialisation is Failure - no sub type information
2.U000188     3C      High Speed CAN Communication Bus - bus off

代码如下:

^{pr2}$

连接到MS ACCESS:

cursor1.execute("SELECT Field2 FROM DTC_CODES Where Field1 = '{}'".format(dtc_code))

for row in cursor1.fetchone():
   print row
DTC_Description.append(row)

cursor2 = connection.cursor()
cursor2.execute("SELECT Field2 FROM FAULT_TYPES Where Field1 = '{}'".format(DTCLogged[loopindex+2]))
for row1 in cursor2.fetchone():
    DTC_Description1.append(row1)

loopindex = loopindex+4


UserInput()

Tags: infromformatforexecutewhereselectcan
1条回答
网友
1楼 · 发布于 2024-05-03 12:57:58

anchor=W指定标签内文本的哪一面。它不影响标签相对于其他标签的显示位置。在

除非您另有指定,pack使用选项side='top'。因此,Label(UI_MainForm, text= temp_text).pack(anchor = W)将把这个标签放在窗口中其他任何东西的下方。在

如果您希望所有内容都在水平线上,请使用side='left'

Label(UI_MainForm, text= temp_text).pack(side='left', anchor = W)

相关问题 更多 >