Tkinter在不同的电脑上看起来不一样

2024-04-29 18:57:59 发布

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

我的tkinter窗口在不同的计算机上看起来非常不同(运行在相同的分辨率上!)以下内容:

窗口8 windows 8

windows 7 windows 7

我希望它看起来像第一次那样。有什么想法吗?

我的代码如下:

class Application():
    def __init__(self):
        self.app = Tk()
        self.app.wm_iconbitmap('.\data\spider.ico')
        self.app.wm_title("Spider Crawler")
        self.app.minsize(width=914, height=331)
        self.app.maxsize(width=914, height=331)

        mainmainleft = Frame(self.app)
        bottom = Frame(self.app)

        mainleft = Frame(mainmainleft)
        itemoptions = Frame(bottom)
        self.graph = multilist.McListBox(bottom)

        startn = Frame(mainleft)
        options = Frame(mainleft)
        hourcredits = Frame(mainleft)

        hoursoption = Frame(hourcredits)
        credits = Frame(hourcredits)

        allbuttons = Frame(mainleft)

        fstart = Frame(startn)

        bp = Frame(allbuttons)
        buttons = Frame(allbuttons)

        self.SchemaUpdate = BooleanVar()
        self.reset = BooleanVar()
        self.genuine = BooleanVar()
        self.buds = BooleanVar()
        self.bills = BooleanVar()
        self.unusual = BooleanVar()
        self.maxs = BooleanVar()
        self.bmoc = BooleanVar()
        self.salvage = BooleanVar()
        self.traded = BooleanVar()
        self.entryid = StringVar()

        self.clicked = False

        for i in [self.reset, self.buds, self.unusual, self.maxs, self.salvage]:
            i.set(True)

        self.b = Button(fstart, text="START", command=self.start)
        c = Button(buttons, text="Steam", command=self.steam).pack(side=LEFT, padx=(0,7))
        d = Button(buttons, text="GotoBP", command=self.backpack).pack(side=LEFT)
        self.b.pack(side=LEFT)

        buttons.pack()
        self.var = StringVar(self.app)
        self.var.set("backpack.tf/profiles/")

        option = OptionMenu(bp, self.var, "backpack.tf/profiles/", "tf2items.com/profiles/", "tf2b.com/tf2/")
        option.config(width = 18)
        option.pack()
        bp.pack(side = BOTTOM)    

        self.box = Entry(startn, textvariable=self.entryid, fg = "gray")
        self.box.bind("<Button-1>", self.callback)
        self.box.insert(0, "Enter steamid")
        self.box.pack(side = TOP, anchor=N, padx =(5,25), pady = 10)

        Label(credits, text="Created by Akenne", font=("Times New Roman", 8)).pack(anchor = E, pady = (0,25))

        credits.pack(side=TOP, anchor=E)

        Label(hoursoption, text="Max Hours:").pack(side=LEFT, padx = (0,10))

        self.hours=IntVar()
        self.hours.set(250)
        Entry(hoursoption,textvariable=self.hours,width=5).pack(side=LEFT)

        hoursoption.pack(padx= (0,45))

        Checkbutton(options, text = "Reload item schema", variable = self.SchemaUpdate).pack(side=TOP, anchor=W, pady =(0, 3))
        Checkbutton(options, text = "Start with fresh id", variable = self.reset).pack(side=TOP, anchor=W)
        Checkbutton(itemoptions, text = "Only never traded items", variable = self.traded).pack(side=TOP, anchor=W)
        Checkbutton(itemoptions, text = "Genuines", variable = self.genuine).pack(side=TOP, anchor=W)
        Checkbutton(itemoptions, text = "Earbuds", variable = self.buds).pack(side=TOP, anchor=W)
        Checkbutton(itemoptions, text = "Bill's", variable = self.bills).pack(side=TOP, anchor=W)
        Checkbutton(itemoptions, text = "Unusuals", variable = self.unusual).pack(side=TOP, anchor=W)
        Checkbutton(itemoptions, text = "Max's items", variable = self.maxs).pack(side=TOP, anchor=W)
        Checkbutton(itemoptions, text = "BMOCs", variable = self.bmoc).pack(side=TOP, anchor=W)
        Checkbutton(itemoptions, text = "Salvaged crates", variable = self.salvage).pack(side=TOP, anchor=W)
        self.lbl = Label(fstart, text="0/0 found")
        self.lbl.pack(side = LEFT, anchor = W, padx = (20,30))

        fstart.pack(side=TOP)

        startn.pack(side=LEFT, anchor = W, padx = (10, 0))
        options.pack(side=LEFT, padx=(0,30), pady = (5,0))
        allbuttons.pack(side=LEFT, pady=(10,0), padx = (40,0))
        hourcredits.pack(side=LEFT, padx = (95,0), anchor = E)

        mainleft.pack(side = TOP, anchor = W)
        self.graph.container.pack(side = LEFT, anchor = W, pady = 10)
        itemoptions.pack(side=LEFT, anchor = E, padx=7)

        mainmainleft.pack(side = TOP, fill = X)
        bottom.pack(padx =10)
        self.app.mainloop()

Tags: textselfapptopleftvariableframeside