【发布时间】:2018-08-25 04:45:15
【问题描述】:
我对@987654321@ 有点陌生。我尝试在左侧的0,0 创建一个Text 小部件,但它出现在中间,就像默认的pack()。
这是我的代码:
from Tkinter import *
# the ui of the main window
class Ui(object):
# the init of the client object
def __init__(self):
self.root = Tk()
self.mid_height = self.root.winfo_screenheight() / 2
self.mid_width = self.root.winfo_screenwidth() / 2
self.root.title("Journey-opening")
self.root.geometry("600x600+{}+{}".format(self.mid_width - 300, self.mid_height - 300))
self.root.resizable(width=0, height=0)
self.cyan = "#0990CB"
self.root["background"] = self.cyan
self.frame = Frame(self.root)
self.frame.pack()
self.chat_box = Text(self.frame, height=30, width=50)
self.chat_box.pack(side=LEFT)
def open(self):
self.root.mainloop()
wins = Ui()
wins.open()
我也尝试了grid 方法,但它没有改变任何东西,并且还创建了另一个小部件,因为它可能至少需要 2 个小部件。
我猜它与我的框架有关,但我按照教程进行操作,一切似乎都很好。
【问题讨论】:
标签: tkinter python python-2.7 layout tkinter