本文整理汇总了Python中Tkinter.Tk.deiconify方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.deiconify方法的具体用法?Python Tk.deiconify怎么用?Python Tk.deiconify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.Tk
的用法示例。
在下文中一共展示了Tk.deiconify方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GUI
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import deiconify [as 别名]
class GUI():
def __init__(self):
self.root = Tk()
self.show()
def show(self):
self.root.deiconify()
#self.root.attributes('-topmost', 1)
#self.root.attributes('-topmost', 0)
self.root.after(2000, self.hide)
def hide(self):
self.root.iconify()
self.root.after(2000, self.show)
示例2: get_files
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import deiconify [as 别名]
def get_files(titlestring,filetype = ('.txt','*.txt')):
# Make a top-level instance and hide since it is ugly and big.
root = Tk()
root.withdraw()
# Make it almost invisible - no decorations, 0 size, top left corner.
root.overrideredirect(True)
root.geometry('0x0+0+0')
#
# Show window again and lift it to top so it can get focus,
# otherwise dialogs will end up behind the terminal.
root.deiconify()
root.attributes("-topmost",1)
root.focus_force()
filenames = []
filenames = tkFileDialog.askopenfilename(title=titlestring, filetypes=[filetype],multiple='True')
#do nothing if already a python list
if filenames == "":
print "You didn't open anything!"
return
root.destroy()
if isinstance(filenames,list):
result = filenames
elif isinstance(filenames,tuple):
result = list(filenames)
else:
#http://docs.python.org/library/re.html
#the re should match: {text and white space in brackets} AND anynonwhitespacetokens
#*? is a non-greedy match for any character sequence
#\S is non white space
#split filenames string up into a proper python list
result = re.findall("{.*?}|\S+",filenames)
#remove any {} characters from the start and end of the file names
result = [ re.sub("^{|}$","",i) for i in result ]
result.sort()
return result
示例3: _init_ui
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import deiconify [as 别名]
def _init_ui(self):
root = Tk()
root.title("pylens")
root.bind("<FocusOut>", self.close)
root.bind("<Escape>", self.close)
# center the window
root.withdraw()
root.update_idletasks() # Update "requested size" from geometry manager
x = (root.winfo_screenwidth() - root.winfo_reqwidth()) / 2
y = (root.winfo_screenheight() - root.winfo_reqheight()) / 2
root.geometry("+%d+%d" % (x, y))
root.deiconify()
text = Text(root)
text.config(width=60, height=1)
text.pack(side=LEFT, fill=Y)
text.bind("<Return>", self.handle_query)
text.focus_force()
return root, text
示例4: TkApplicationWindow
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import deiconify [as 别名]
class TkApplicationWindow(AbstractApplicationWindow):
def __init__(self, app):
self.root = Tk()
self.root.title("Llia")
self.root.config(background=factory.bg())
super(TkApplicationWindow, self).__init__(app, self.root)
self.root.withdraw()
if app.config()["enable-splash"]:
splash = TkSplashWindow(self.root, app)
self.root.deiconify()
self.root.protocol("WM_DELETE_WINDOW", self.exit_app)
self.llia_graph = None
self._main = layout.BorderFrame(self.root)
self._main.config(background=factory.bg())
self._main.pack(anchor="nw", expand=True, fill=BOTH)
self._progressbar = None
self._init_status_panel()
self._init_menu()
self._init_center_frame(self._main.center)
self.root.minsize(width=665, height=375)
self.group_windows = []
self.add_synth_group()
self._scene_filename = ""
def _init_status_panel(self):
south = self._main.south
south.configure(padx=4, pady=4)
self._lab_status = factory.label(south, "", modal=False)
b_panic = factory.panic_button(south)
b_down = factory.button(south, "-")
b_up = factory.button(south, "+")
b_panic.grid(row=0, column=0)
self._progressbar = Progressbar(south,mode="indeterminate")
self._progressbar.grid(row=0,column=PROGRESSBAR_COLUMN, sticky='w', padx=8)
self._lab_status.grid(row=0,column=4, sticky='w')
south.config(background=factory.bg())
b_down.configure(command=lambda: self.root.lower())
b_up.configure(command=lambda: self.root.lift())
self.update_progressbar(100, 0)
def _tab_change_callback(self, event):
self.llia_graph.sync()
def _init_center_frame(self, master):
nb = ttk.Notebook(master)
nb.pack(expand=True, fill="both")
frame_synths = layout.FlowGrid(nb, 6)
frame_efx = layout.FlowGrid(nb, 6)
frame_controllers = layout.FlowGrid(nb, 6)
self.llia_graph = LliaGraph(nb, self.app)
nb.add(frame_synths, text = "Synths")
nb.add(frame_efx, text = "Effects")
nb.add(frame_controllers, text = "Controllers")
nb.add(self.llia_graph, text="Graph")
nb.bind("<Button-1>", self._tab_change_callback)
def display_info_callback(event):
sp = event.widget.synth_spec
msg = "%s: %s" % (sp["format"],sp["description"])
self.status(msg)
def clear_info_callback(*_):
self.status("")
for st in con.SYNTH_TYPES:
sp = specs[st]
ttp = "Add %s Synthesizer (%s)" % (st, sp["description"])
b = factory.logo_button(frame_synths, st, ttip=ttp)
b.synth_spec = sp
b.bind("<Button-1>", self._show_add_synth_dialog)
b.bind("<Enter>", display_info_callback)
b.bind("<Leave>", clear_info_callback)
frame_synths.add(b)
for st in con.EFFECT_TYPES:
sp = specs[st]
ttp = "Add %s Effect (%s)" % (st, sp["description"])
b = factory.logo_button(frame_efx, st, ttip=ttp)
b.synth_spec = sp
b.bind("<Button-1>", self._show_add_efx_dialog)
b.bind("<Enter>", display_info_callback)
b.bind("<Leave>", clear_info_callback)
frame_efx.add(b)
for st in con.CONTROLLER_SYNTH_TYPES:
sp = specs[st]
ttp = "Add %s Effect (%s)" % (st, sp["description"])
b = factory.logo_button(frame_controllers, st, ttip=ttp)
b.synth_spec = sp
b.bind("<Button-1>", self._show_add_controller_dialog)
b.bind("<Enter>", display_info_callback)
b.bind("<Leave>", clear_info_callback)
frame_controllers.add(b)
@staticmethod
def menu(master):
m = Menu(master, tearoff=0)
m.config(background=factory.bg(), foreground=factory.fg())
return m
def _init_menu(self):
#.........这里部分代码省略.........
示例5: Tk
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import deiconify [as 别名]
class TkApplication:
# these are passed to Tk() and must be redefined by the subclasses:
tk_basename = ''
tk_class_name = ''
def __init__(self, screen_name=None, geometry=None):
self.init_tk(screen_name, geometry)
def init_tk(self, screen_name=None, geometry=None):
self.root = Tk(screenName=screen_name, baseName=self.tk_basename, className=self.tk_class_name)
app.root = self.root
from sk1.managers.uimanager import UIManager
app.uimanager = UIManager(self.root)
self.splash = SplashScreen(self.root)
self.splash.show()
self.splash.set_val(.1, 'DialogManager initialization...')
from sk1.managers.dialogmanager import DialogManager
app.dialogman = DialogManager(self.root)
self.splash.set_val(.15, 'Setting appication data...')
app.info1 = StringVar(self.root, '')
app.info2 = StringVar(self.root, '')
app.info3 = DoubleVar(self.root, 0)
# Reset locale again to make sure we get properly translated
# messages if desired by the user. For some reason it may
# have been reset by Tcl/Tk.
# if this fails it will already have failed in
# app/__init__.py which also prints a warning.
try:
import locale
except ImportError:
pass
else:
try:
locale.setlocale(locale.LC_MESSAGES, "")
except:
pass
if not geometry:
# try to read geometry from resource database
geometry = self.root.option_get('geometry', 'Geometry')
if geometry:
try:
self.root.geometry(geometry)
except TclError:
sys.stderr.write('%s: invalid geometry specification %s' % (self.tk_basename, geometry))
def Mainloop(self):
self.splash.set_val(1)
self.root.update()
self.root.deiconify()
self.root.after(300, self.splash.hide)
self.root.mainloop()
def MessageBox(self, *args, **kw):
return apply(tkext.MessageDialog, (self.root,) + args, kw)
def GetOpenFilename(self, **kwargs):
return apply(tkext.GetOpenFilename, (self.root,), kwargs)
def GetSaveFilename(self, **kwargs):
return apply(tkext.GetSaveFilename, (self.root,), kwargs)
clipboard = None
def EmptyClipboard(self):
self.SetClipboard(None)
def SetClipboard(self, data):
self.clipboard = data
def GetClipboard(self):
return self.clipboard
def ClipboardContainsData(self):
return self.clipboard is not None
示例6: repr
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import deiconify [as 别名]
total, lags, visibility, phase_fit, m, c) = correlator.get_correlation()
baseline = left, right
logger.debug('received baseline %s' % repr(baseline))
except NoCorrelations:
widget.after(1, update_plots, widget, baselines)
return # it never comes to this
if baseline not in baselines.keys():
corr.axes.grid()
#corr.axes.set_xlabel('Lag', size='large')
#corr.axes.set_ylabel('Correlation Function', size='large')
phase_line = corr.plot(f, angle(visibility), '%so' % colors[current%len(colors)], linewidth=1, label=repr(baseline))[0]
fit_line = corr.plot(f, real(phase_fit), '%s-' % colors[current%len(colors)], linewidth=1, label=None)[0]
baselines[baseline] = phase_line, fit_line
else:
corr.axes.legend()
phase_line, fit_line = baselines[baseline]
corr.update_line(phase_line, f, angle(visibility))
corr.update_line(fit_line, f, real(phase_fit))
if current == total-1:
widget.update()
logger.info('update in')
widget.after_idle(update_plots, widget, baselines)
root.update()
root.geometry(frame.winfo_geometry())
root.after_idle(update_plots, root, {})
root.deiconify()
root.mainloop()
示例7: runADT
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import deiconify [as 别名]
#.........这里部分代码省略.........
mv.browseCommands('autostart41Commands', commands = None,
package = 'AutoDockTools')
mv.browseCommands('autoanalyze41Commands', commands = None,
package = 'AutoDockTools')
#mv.GUI.currentADTBar = 'AutoTools42Bar'
#setADTmode("AD4.0", mv)
setADTmode("AD4.2", mv)
mv.browseCommands('selectionCommands', package='Pmv')
mv.browseCommands('AutoLigandCommand', package='AutoDockTools', topCommand=0)
mv.GUI.naturalSize()
mv.customize('_adtrc')
mv.help_about = about
if gui:
font = mv.GUI.ROOT.option_get('font', '*')
mv.GUI.ROOT.option_add('*font', font)
try:
import Vision
mv.browseCommands('visionCommands', commands=('vision',), topCommand=0)
mv.browseCommands('coarseMolSurfaceCommands', topCommand=0)
if hasattr(mv,'vision') and mv.vision.ed is None:
mv.vision(log=0)
else:
# we address the global variable in vision
Vision.ed = mv.vision.ed
except ImportError:
pass
#show the application after it built
if gui:
splash.finish()
root.deiconify()
globals().update(locals())
if gui:
mv.GUI.VIEWER.suspendRedraw = True
cwd = os.getcwd()
#mv._cwd differs from cwd when 'Startup Directory' userpref is set
os.chdir(mv._cwd)
if dmode is not None or cmode is not None:
# save current list of commands run when a molecule is loaded
addCmds = mv.getOnAddObjectCmd()
# remove them
if dmode is not None:
for c in addCmds:
mv.removeOnAddObjectCmd(c[0])
# set the mode
setdmode(dmode, mv)
if cmode is not None:
# set the mode
setcmode(cmode, mv)
for a in args:
if a[0]=='-':# skip all command line options
continue
elif (a[-10:]=='_pmvnet.py') or (a[-7:]=='_net.py'): # Vision networks
mv.browseCommands('visionCommands', commands=('vision',) )
if mv.vision.ed is None:
mv.vision()
mv.vision.ed.loadNetwork(a)
if visionarg == 'run' or visionarg == 'once':
mv.vision.ed.softrunCurrentNet_cb()
示例8: EngineGui
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import deiconify [as 别名]
#.........这里部分代码省略.........
self.currentVoice = StringVar(self.tkRoot)
self.currentVoice.set(self.communicationProtocal.CurrentVoiceName)
engine = pyttsx.init()
voices = engine.getProperty("voices")
voiceNames = list()
for x in xrange(0, len(voices)):
voiceNames.append(voices[x].name)
self.optionMenuVoices = OptionMenu(frame, self.currentVoice, *tuple(voiceNames), command=self.CallBackOptionMenuVoices)
self.optionMenuVoices.config(width=500)
self.optionMenuVoices.grid(sticky=W, row = 12, column = 1)
#hide if close button is clicked
self.tkRoot.protocol("WM_DELETE_WINDOW", self.HideGui)
self.tkRoot.after(1000/32, self.Update)
self.tkRoot.mainloop()
def Update(self):
wordLocation = self.communicationProtocal.OnWordStartLocation
wordLength = self.communicationProtocal.OnWordLength
wordTotal = self.communicationProtocal.OnWordTotal
if wordLocation:
self.labelStart.configure(text=wordLocation)
else:
self.labelStart.configure(text="0")
self.labelLength.configure(text=wordLength)
if wordLength != 0 and wordTotal == 0:
self.labelTotal.configure(text="Introduce")
else:
self.labelTotal.configure(text=wordTotal)
if len(self.communicationProtocal.SpeakQueue) != 0:
if (wordLocation < 25):
self.labelSentenceLeft.configure(text=str(self.communicationProtocal.SpeakQueue[0])[0:wordLocation])
else:
self.labelSentenceLeft.configure(text=str(self.communicationProtocal.SpeakQueue[0])[wordLocation-25:wordLocation])
self.labelSentenceSpoken.configure(text=str(self.communicationProtocal.SpeakQueue[0])[wordLocation:wordLocation+wordLength])
if (wordTotal - wordLocation - wordLength < 25):
self.labelSentenceRight.configure(text=str(self.communicationProtocal.SpeakQueue[0])[wordLocation+wordLength:wordTotal])
else:
self.labelSentenceRight.configure(text=str(self.communicationProtocal.SpeakQueue[0])[wordLocation+wordLength:wordLocation+wordLength+25])
else:
self.labelSentenceLeft.configure(text="...")
self.labelSentenceSpoken.configure(text="...")
self.labelSentenceRight.configure(text="...")
if (self.communicationProtocal.SpeakQueue != None and self.listboxQueueToSpeak.size() != len(self.communicationProtocal.SpeakQueue)):
self.listboxQueueToSpeak.delete(0,self.listboxQueueToSpeak.size())
for x in xrange(0,len(self.communicationProtocal.SpeakQueue)):
self.listboxQueueToSpeak.insert(x, str(x)+": "+self.communicationProtocal.SpeakQueue[x])
if (self.currentVoice.get() != self.communicationProtocal.CurrentVoiceName):
self.currentVoice.set(self.communicationProtocal.CurrentVoiceName)
if self.speedValue != self.communicationProtocal.CurrentRate:
self.intVarSpeed.set(self.communicationProtocal.CurrentRate)
self.speedValue = self.communicationProtocal.CurrentRate
if self.recoverActionLabelText != self.communicationProtocal.recoveryTask:
self.recoverActionLabelText = self.communicationProtocal.recoveryTask
self.labelRecoverAction.configure(text=self.recoverActionLabelText)
if self.GUIVisible != self.communicationProtocal.GUIVisible:
# self.GUIVisible ? self.HideGui : self.ShowGui
self.HideGui() if self.GUIVisible else self.ShowGui()
self.tkRoot.after(1000/32,self.Update)
def OnValidateEntrySpeakSpeed(self, d, i, P, s, S, v, V, W):
try :
int(S)
return True
except ValueError:
return False
def CallBackSetSpeed(self):
self.communicationProtocal.handleSetSpeed(self.intVarSpeed.get())
def CallBackReturnSay(self, event):
self.CallBackButtonSay()
def CallBackButtonSay(self):
self.communicationProtocal.handleSay(self.stringVarTextToSay.get())
def CallBackOptionMenuVoices(self, selectedItem):
self.communicationProtocal.handleSetVoice(selectedItem)
def Close(self):
self.tkRoot.quit()
def HideGui(self):
self.GUIVisible = False
self.communicationProtocal.GUIVisible = False
self.tkRoot.withdraw()
def ShowGui(self):
self.GUIVisible = True
self.communicationProtocal.GUIVisible = True
self.tkRoot.deiconify()
示例9: __init__
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import deiconify [as 别名]
#.........这里部分代码省略.........
Checkbutton(self.root,text='9',command=lambda :self.processCardChoice(8))]]
#See the comment above setup Novice _Field.
def setupAdvancedField(self):
self._destroyAllButtons() if self.buttonField else None
self.buttonField = [[Button(self.root,command=lambda :self.processCardChoice(0)),
Button(self.root,command=lambda :self.processCardChoice(1)),
Button(self.root,command=lambda :self.processCardChoice(2)),
Button(self.root,command=lambda :self.processCardChoice(3))],
[Button(self.root,command=lambda :self.processCardChoice(4)),
Button(self.root,command=lambda :self.processCardChoice(5)),
Button(self.root,command=lambda :self.processCardChoice(6)),
Button(self.root,command=lambda :self.processCardChoice(7))],
[Button(self.root,command=lambda :self.processCardChoice(8)),
Button(self.root,command=lambda :self.processCardChoice(9)),
Button(self.root,command=lambda :self.processCardChoice(10)),
Button(self.root,command=lambda :self.processCardChoice(11))]]
self.checkButtonField = [[Checkbutton(self.root,text='1',command=lambda :self.processCardChoice(0)),
Checkbutton(self.root,text='2',command=lambda :self.processCardChoice(1)),
Checkbutton(self.root,text='3',command=lambda :self.processCardChoice(2)),
Checkbutton(self.root,text='4',command=lambda :self.processCardChoice(3))],
[Checkbutton(self.root,text='5',command=lambda :self.processCardChoice(4)),
Checkbutton(self.root,text='6',command=lambda :self.processCardChoice(5)),
Checkbutton(self.root,text='7',command=lambda :self.processCardChoice(6)),
Checkbutton(self.root,text='8',command=lambda :self.processCardChoice(7))],
[Checkbutton(self.root,text='9',command=lambda :self.processCardChoice(8)),
Checkbutton(self.root,text='10',command=lambda :self.processCardChoice(9)),
Checkbutton(self.root,text='11',command=lambda :self.processCardChoice(10)),
Checkbutton(self.root,text='12',command=lambda :self.processCardChoice(11))]]
def updateCardsOnField(self,cardField):
rows = cardField.rows()
cols = cardField.cols()
if cols == 3:
self.setupNoviceField()
elif cols == 4:
self.setupAdvancedField()
else:
raise IndexError("CardField argument has illegal number of columns")
assert len(self.buttonField) == rows
assert len(self.buttonField[0]) == cols
spacing = (GUIHandler.windowwidth-(cols * Card.pixelWidth) - 5) / (cols-1)
x,y = 0,0
cbwidth = self.checkButtonField[0][0].winfo_reqwidth()
for i in xrange(rows):
for j in xrange(cols):
pic = PhotoImage(file='../media/%s.gif' % str(cardField[i][j].getCardImgNumber()))
self.buttonField[i][j].config(image=pic)
self.buttonField[i][j].image = pic
self.buttonField[i][j].place(x=x,y=y)
self.checkButtonField[i][j].place(x=x + Card.pixelWidth//2 - cbwidth//4,y=(y+Card.pixelHeight+10))
x += Card.pixelWidth + spacing
y += Card.pixelHeight + 40
x = 0
def startNewGame(self):
self.userSetsHeight = 0
[i.destroy() for i in self.userSetsCreated.children.values()]
self.Game.resetGame()
self.updateCardsOnField(self.Game.field)
self.remainderLabel.config(text="There are %d set(s) remaining on the board." % self.Game.numSetsTotal)
#print map(lambda ls:map(lambda x:x+1,ls),self.Game.setsListTotal)
def _destroyAllButtons(self):
for i in self.buttonField:
for j in i:
j.destroy()
for i in self.checkButtonField:
for j in i:
j.destroy()
def changeGameDifficulty(self,difficulty):
if self.Game.changeGameDifficulty(difficulty):
self.startNewGame()
def getHint(self):
result = self.Game.callHint()
if result == -3:
showinfo("One set remains","You cannot use hints in finding the last set.")
elif result == -2:
showinfo("Game's over","Game has ended. Start a new game if you wish.")
elif result == -1:
showinfo("No more hints","Sorry. You are out of hints to spare.")
else:
showinfo("Your Hint","Pick Card #%d"%(result+1))
def run(self):
self.root.deiconify()
self.root.mainloop()
示例10: set_dir
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import deiconify [as 别名]
def set_dir(titlestring):
# Make a top-level instance and hide since it is ugly and big.
root = Tk()
root.withdraw()
# Make it almost invisible - no decorations, 0 size, top left corner.
root.overrideredirect(True)
root.geometry('0x0+0+0')
#
# Show window again and lift it to top so it can get focus,
# otherwise dialogs will end up behind the terminal.
root.deiconify()
root.attributes("-topmost",1)
root.focus_force()
file_path = tkFileDialog.askdirectory(parent=root,title=titlestring)
if file_path != "":
return str(file_path)
else:
print "you didn't open anything!"
# Get rid of the top-level instance once to make it actually invisible.
root.destroy()