在这个GUI应用程序中,simpleapp是主要窗口。作为初始化simpleapp的一部分,我尝试设置应用程序的主目录,使用类setHomeDir打开窗口,以便确认/设置当前的工作目录。首先,我无法将当前工作目录显示在setHomeDir窗口中,即无法使self.entryVariable.set(home)工作。
我哪里出问题了?
import Tkinter, os
class simpleapp(Tkinter.Tk):
def __init__(self,parent):
Tkinter.Tk.__init__(self,parent)
se
下面有一段简化的代码,它首先打开一个空的tkinter窗口,然后,一旦关闭了这个tkinter窗口,它就会打开一个pyglet窗口。
我怎么能强迫这两个窗户同时打开呢?
下面的链接中有一个类似的问题,关于同时使用toplevel()打开两个tkinter窗口,但我不认为它适用于我的问题。
提前感谢
import pyglet
from tkinter import *
# Open's a tkinter window
root = Tk()
mainloop()
# Open's a Pyglet Window only after the tkinter
我是'Tkinter‘库的新手,我想知道如何在打开新窗口时禁用按钮。例如,如果单击主窗口上的按钮,将打开一个新窗口,并禁用主窗口上的所有按钮。关闭窗口后,应再次重新启用按钮。
下面是我的代码示例:
from tkinter import *
root = Tk()
def z():
w = Toplevel()
bu = Button(w, text = "Click!", font = 'bold')
bu.pack()
b = Button(root, text = "Click!", command
我正在运行Windows 7,安装了Python3.3 64位。在导入tkinter模块时,我似乎遇到了问题,我可以通过python很好地导入它,并且它会工作,但是当我保存.py文件并双击它时,一个cmd窗口将打开并说:
Traceback (most recent call last):
File "C:Users\username\Desktop\g.py", line 3, in <module>
from tkinter import *
ImportError: No module named tkinter
我尝试了以下几点:
我尝试过import
编辑:让我包含我的代码,这样我就可以获得一些特定的帮助。
import Tkinter
def goPush():
win2=Tkinter.Toplevel()
win2.geometry('400x50')
Tkinter.Label(win2,text="If you have prepared as Help describes select Go otherwise select Go Back").pack()
Tkinter.Button(win2,text="Go",command=bounceP
我尝试通过多个线程打开多个框架。这是我的代码。
'''
This is the module for test and studying.
Author:Roger
Date: 2010/10/10
Python version: 2.6.5
'''
import threading, Tkinter
class Application(Tkinter.Frame):
def __init__(self, master=None):
Tkinter.Frame.__init__(self, master)
我正在使用TKinter创建图形用户界面,主窗口可以从它的主菜单中打开它自己的新实例。
然而,当我创建一个新的窗口实例时,本应出现在画布上的图像却没有出现。有谁能帮上忙吗?
这是我的GUI代码:
class MainPage:
def __init__(self, master):
master.title("EIL Viewer")
master.geometry('1000x650')
#creating the main menu
master.option_add('*
当用户单击按钮(仍然需要创建)时,我将如何创建一个新窗口?我已经拿出了一些代码来缩短这段时间。我需要一个按钮创建,当他们点击那个按钮,一个新的窗口打开。我还没有创建按钮,因为该按钮必须链接到新窗口。请帮帮忙
My imports...
class App:
def __init__(self, master):
self.master = master
# call start to initialize to create the UI elemets
self.start()
def start(self):
我希望窗口中有一个按钮来打开一个新窗口并关闭前一个窗口。这两个按钮都有可能有一个按钮吗?我在下面的代码中尝试过,但它没有工作,只是告诉我没有定义窗口:
import tkinter
def window1():
window = tkinter.Tk()
tkinter.Button(window, text = "Next", command = window2).pack()
window.mainloop()
def window2():
window.destroy() #This is where the error is
me