Python Tkinter.Toplevel() Examples
The following are 30
code examples of Tkinter.Toplevel().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
Tkinter
, or try the search function
.
Example #1
Source File: annotation_gui.py From SEM with MIT License | 9 votes |
def preferences(self, event=None): preferenceTop = tkinter.Toplevel() preferenceTop.focus_set() notebook = ttk.Notebook(preferenceTop) frame1 = ttk.Frame(notebook) notebook.add(frame1, text='general') frame2 = ttk.Frame(notebook) notebook.add(frame2, text='shortcuts') c = ttk.Checkbutton(frame1, text="Match whole word when broadcasting annotation", variable=self._whole_word) c.pack() shortcuts_vars = [] shortcuts_gui = [] cur_row = 0 j = -1 frame_list = [] frame_list.append(ttk.LabelFrame(frame2, text="common shortcuts")) frame_list[-1].pack(fill="both", expand="yes") for i, shortcut in enumerate(self.shortcuts): j += 1 key, cmd, bindings = shortcut name, command = cmd shortcuts_vars.append(tkinter.StringVar(frame_list[-1], value=key)) tkinter.Label(frame_list[-1], text=name).grid(row=cur_row, column=0, sticky=tkinter.W) entry = tkinter.Entry(frame_list[-1], textvariable=shortcuts_vars[j]) entry.grid(row=cur_row, column=1) cur_row += 1 notebook.pack() # # ? menu methods #
Example #2
Source File: viewer.py From networkx_viewer with GNU General Public License v3.0 | 7 votes |
def __init__(self, main_window, msg='Please enter a node:'): tk.Toplevel.__init__(self) self.main_window = main_window self.title('Node Entry') self.geometry('170x160') self.rowconfigure(3, weight=1) tk.Label(self, text=msg).grid(row=0, column=0, columnspan=2, sticky='NESW',padx=5,pady=5) self.posibilities = [d['dataG_id'] for n,d in main_window.canvas.dispG.nodes_iter(data=True)] self.entry = AutocompleteEntry(self.posibilities, self) self.entry.bind('<Return>', lambda e: self.destroy(), add='+') self.entry.grid(row=1, column=0, columnspan=2, sticky='NESW',padx=5,pady=5) tk.Button(self, text='Ok', command=self.destroy).grid( row=3, column=0, sticky='ESW',padx=5,pady=5) tk.Button(self, text='Cancel', command=self.cancel).grid( row=3, column=1, sticky='ESW',padx=5,pady=5) # Make modal self.winfo_toplevel().wait_window(self)
Example #3
Source File: backend_tkagg.py From Computable with MIT License | 6 votes |
def showtip(self, text): "Display text in tooltip window" self.text = text if self.tipwindow or not self.text: return x, y, _, _ = self.widget.bbox("insert") x = x + self.widget.winfo_rootx() + 27 y = y + self.widget.winfo_rooty() self.tipwindow = tw = Tk.Toplevel(self.widget) tw.wm_overrideredirect(1) tw.wm_geometry("+%d+%d" % (x, y)) try: # For Mac OS tw.tk.call("::tk::unsupported::MacWindowStyle", "style", tw._w, "help", "noActivates") except Tk.TclError: pass label = Tk.Label(tw, text=self.text, justify=Tk.LEFT, background="#ffffe0", relief=Tk.SOLID, borderwidth=1, ) label.pack(ipadx=1)
Example #4
Source File: CallTipWindow.py From oss-ftp with MIT License | 6 votes |
def _calltip_window(parent): # htest # from Tkinter import Toplevel, Text, LEFT, BOTH top = Toplevel(parent) top.title("Test calltips") top.geometry("200x100+%d+%d" % (parent.winfo_rootx() + 200, parent.winfo_rooty() + 150)) text = Text(top) text.pack(side=LEFT, fill=BOTH, expand=1) text.insert("insert", "string.split") top.update() calltip = CallTip(text) def calltip_show(event): calltip.showtip("(s=Hello world)", "insert", "end") def calltip_hide(event): calltip.hidetip() text.event_add("<<calltip-show>>", "(") text.event_add("<<calltip-hide>>", ")") text.bind("<<calltip-show>>", calltip_show) text.bind("<<calltip-hide>>", calltip_hide) text.focus_set()
Example #5
Source File: ColorDelegator.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
def _color_delegator(parent): # htest # from Tkinter import Toplevel, Text from idlelib.Percolator import Percolator top = Toplevel(parent) top.title("Test ColorDelegator") top.geometry("200x100+%d+%d" % (parent.winfo_rootx() + 200, parent.winfo_rooty() + 150)) source = "if somename: x = 'abc' # comment\nprint\n" text = Text(top, background="white") text.pack(expand=1, fill="both") text.insert("insert", source) text.focus_set() p = Percolator(text) d = ColorDelegator() p.insertfilter(d)
Example #6
Source File: EditorWindow.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
def display(self, parent, near=None): """ Display the help dialog. parent - parent widget for the help window near - a Toplevel widget (e.g. EditorWindow or PyShell) to use as a reference for placing the help window """ import warnings as w w.warn("EditorWindow.HelpDialog is no longer used by Idle.\n" "It will be removed in 3.6 or later.\n" "It has been replaced by private help.HelpWindow\n", DeprecationWarning, stacklevel=2) if self.dlg is None: self.show_dialog(parent) if near: self.nearwindow(near)
Example #7
Source File: dynOptionMenuWidget.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
def _dyn_option_menu(parent): # htest # from Tkinter import Toplevel top = Toplevel() top.title("Tets dynamic option menu") top.geometry("200x100+%d+%d" % (parent.winfo_rootx() + 200, parent.winfo_rooty() + 150)) top.focus_set() var = StringVar(top) var.set("Old option set") #Set the default value dyn = DynOptionMenu(top,var, "old1","old2","old3","old4") dyn.pack() def update(): dyn.SetMenu(["new1","new2","new3","new4"], value="new option set") button = Button(top, text="Change option set", command=update) button.pack()
Example #8
Source File: dynOptionMenuWidget.py From oss-ftp with MIT License | 6 votes |
def _dyn_option_menu(parent): # htest # from Tkinter import Toplevel top = Toplevel() top.title("Tets dynamic option menu") top.geometry("200x100+%d+%d" % (parent.winfo_rootx() + 200, parent.winfo_rooty() + 150)) top.focus_set() var = StringVar(top) var.set("Old option set") #Set the default value dyn = DynOptionMenu(top,var, "old1","old2","old3","old4") dyn.pack() def update(): dyn.SetMenu(["new1","new2","new3","new4"], value="new option set") button = Button(top, text="Change option set", command=update) button.pack()
Example #9
Source File: ColorDelegator.py From oss-ftp with MIT License | 6 votes |
def _color_delegator(parent): # htest # from Tkinter import Toplevel, Text from idlelib.Percolator import Percolator top = Toplevel(parent) top.title("Test ColorDelegator") top.geometry("200x100+%d+%d" % (parent.winfo_rootx() + 200, parent.winfo_rooty() + 150)) source = "if somename: x = 'abc' # comment\nprint\n" text = Text(top, background="white") text.pack(expand=1, fill="both") text.insert("insert", source) text.focus_set() p = Percolator(text) d = ColorDelegator() p.insertfilter(d)
Example #10
Source File: __main__.py From tkcalendar with GNU General Public License v3.0 | 6 votes |
def example1(): def print_sel(): print(cal.selection_get()) cal.see(datetime.date(year=2016, month=2, day=5)) top = tk.Toplevel(root) import datetime today = datetime.date.today() mindate = datetime.date(year=2018, month=1, day=21) maxdate = today + datetime.timedelta(days=5) print(mindate, maxdate) cal = Calendar(top, font="Arial 14", selectmode='day', locale='en_US', mindate=mindate, maxdate=maxdate, disabledforeground='red', cursor="hand1", year=2018, month=2, day=5) cal.pack(fill="both", expand=True) ttk.Button(top, text="ok", command=print_sel).pack()
Example #11
Source File: backend_tkagg.py From matplotlib-4-abaqus with MIT License | 6 votes |
def showtip(self, text): "Display text in tooltip window" self.text = text if self.tipwindow or not self.text: return x, y, _, _ = self.widget.bbox("insert") x = x + self.widget.winfo_rootx() + 27 y = y + self.widget.winfo_rooty() self.tipwindow = tw = Tk.Toplevel(self.widget) tw.wm_overrideredirect(1) tw.wm_geometry("+%d+%d" % (x, y)) try: # For Mac OS tw.tk.call("::tk::unsupported::MacWindowStyle", "style", tw._w, "help", "noActivates") except Tk.TclError: pass label = Tk.Label(tw, text=self.text, justify=Tk.LEFT, background="#ffffe0", relief=Tk.SOLID, borderwidth=1, ) label.pack(ipadx=1)
Example #12
Source File: gui.py From snn_toolbox with MIT License | 6 votes |
def edit_experimental_settings(self): """Settings menu for experimental features.""" self.experimental_settings_container = tk.Toplevel(bg='white') self.experimental_settings_container.geometry('300x400') self.experimental_settings_container.wm_title('Experimental settings') self.experimental_settings_container.protocol( 'WM_DELETE_WINDOW', self.experimental_settings_container.destroy) tk.Button(self.experimental_settings_container, text='Save and close', command=self.experimental_settings_container.destroy).pack() experimental_settings_cb = tk.Checkbutton( self.experimental_settings_container, text="Enable experimental settings", variable=self.settings['experimental_settings'], height=2, width=20, bg='white') experimental_settings_cb.pack(expand=True) tip = dedent("""Enable experimental settings.""") ToolTip(experimental_settings_cb, text=tip, wraplength=750)
Example #13
Source File: ImageTk.py From teleport with Apache License 2.0 | 6 votes |
def _show(image, title): """Helper for the Image.show method.""" class UI(tkinter.Label): def __init__(self, master, im): if im.mode == "1": self.image = BitmapImage(im, foreground="white", master=master) else: self.image = PhotoImage(im, master=master) tkinter.Label.__init__(self, master, image=self.image, bg="black", bd=0) if not tkinter._default_root: raise IOError("tkinter not initialized") top = tkinter.Toplevel() if title: top.title(title) UI(top, image).pack()
Example #14
Source File: streams.py From convis with GNU General Public License v3.0 | 6 votes |
def mainloop(self): try: import Tkinter as tk except ImportError: import tkinter as tk from PIL import Image, ImageTk from ttk import Frame, Button, Style import time import socket self.root = tk.Toplevel() #Tk() self.root.title('Display') self.image = Image.fromarray(np.zeros((200,200))).convert('RGB') self.image1 = ImageTk.PhotoImage(self.image) self.panel1 = tk.Label(self.root, image=self.image1) self.display = self.image1 self.frame1 = Frame(self.root, height=50, width=50) self.panel1.pack(side=tk.TOP, fill=tk.BOTH, expand=tk.YES) self.root.after(100, self.advance_image) self.root.after(100, self.update_image) self.root.protocol("WM_DELETE_WINDOW", self.on_closing) #global _started_tkinter_main_loop #if not _started_tkinter_main_loop: # _started_tkinter_main_loop = True # print("Starting Tk main thread...")
Example #15
Source File: ImageTk.py From CNCGToolKit with MIT License | 6 votes |
def _show(image, title): class UI(Tkinter.Label): def __init__(self, master, im): if im.mode == "1": self.image = BitmapImage(im, foreground="white", master=master) else: self.image = PhotoImage(im, master=master) Tkinter.Label.__init__(self, master, image=self.image, bg="black", bd=0) if not Tkinter._default_root: raise IOError, "tkinter not initialized" top = Tkinter.Toplevel() if title: top.title(title) UI(top, image).pack()
Example #16
Source File: ImageTk.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _show(image, title): """Helper for the Image.show method.""" class UI(tkinter.Label): def __init__(self, master, im): if im.mode == "1": self.image = BitmapImage(im, foreground="white", master=master) else: self.image = PhotoImage(im, master=master) tkinter.Label.__init__(self, master, image=self.image, bg="black", bd=0) if not tkinter._default_root: raise IOError("tkinter not initialized") top = tkinter.Toplevel() if title: top.title(title) UI(top, image).pack()
Example #17
Source File: ImageTk.py From lambda-text-extractor with Apache License 2.0 | 6 votes |
def _show(image, title): """Helper for the Image.show method.""" class UI(tkinter.Label): def __init__(self, master, im): if im.mode == "1": self.image = BitmapImage(im, foreground="white", master=master) else: self.image = PhotoImage(im, master=master) tkinter.Label.__init__(self, master, image=self.image, bg="black", bd=0) if not tkinter._default_root: raise IOError("tkinter not initialized") top = tkinter.Toplevel() if title: top.title(title) UI(top, image).pack()
Example #18
Source File: ImageTk.py From lambda-text-extractor with Apache License 2.0 | 6 votes |
def _show(image, title): """Helper for the Image.show method.""" class UI(tkinter.Label): def __init__(self, master, im): if im.mode == "1": self.image = BitmapImage(im, foreground="white", master=master) else: self.image = PhotoImage(im, master=master) tkinter.Label.__init__(self, master, image=self.image, bg="black", bd=0) if not tkinter._default_root: raise IOError("tkinter not initialized") top = tkinter.Toplevel() if title: top.title(title) UI(top, image).pack()
Example #19
Source File: tkconch.py From python-for-android with Apache License 2.0 | 5 votes |
def run(): global menu, options, frame args = sys.argv[1:] if '-l' in args: # cvs is an idiot i = args.index('-l') args = args[i:i+2]+args del args[i+2:i+4] for arg in args[:]: try: i = args.index(arg) if arg[:2] == '-o' and args[i+1][0]!='-': args[i:i+2] = [] # suck on it scp except ValueError: pass root = Tkinter.Tk() root.withdraw() top = Tkinter.Toplevel() menu = TkConchMenu(top) menu.pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=1) options = GeneralOptions() try: options.parseOptions(args) except usage.UsageError, u: print 'ERROR: %s' % u options.opt_help() sys.exit(1)
Example #20
Source File: tooltip.py From darkc0de-old-stuff with GNU General Public License v3.0 | 5 votes |
def _show(self): if self._opts['state'] == 'disabled': self._unschedule() return if not self._tipwindow: self._tipwindow = tw = Tkinter.Toplevel(self.master) # hide the window until we know the geometry tw.withdraw() tw.wm_overrideredirect(1) self.create_contents() tw.update_idletasks() x, y = self.coords() tw.wm_geometry("+%d+%d" % (x, y)) tw.deiconify()
Example #21
Source File: marmot.py From aggregation with Apache License 2.0 | 5 votes |
def __run__(self): # create the welcome window run_type = None t = tkinter.Toplevel(self.root) t.resizable(False,False) frame = ttk.Frame(t, padding="3 3 12 12") frame.grid(column=0, row=0, sticky=(tkinter.N, tkinter.W, tkinter.E, tkinter.S)) frame.columnconfigure(0, weight=1) frame.rowconfigure(0, weight=1) ttk.Label(frame,text="Welcome to Marmot.").grid(column=1,row=1) def setup(require_gold_standard): # this will determine the whole run mode from here on in self.require_gold_standard = require_gold_standard self.subjects = self.__image_select__(require_gold_standard) # if r == "a": # self.subjects = self.project.__get_retired_subjects__(1,True) # self.run_mode = "a" # else: # # when we want to explore subjects which don't have gold standard # # basically creating some as we go # # False => read in all subjects, not just those with gold standard annotations # # todo - takes a while in read in all subjects. Better way? # self.subjects = self.project.__get_retired_subjects__(1,False) # self.run_mode = "b" random.shuffle(self.subjects) self.__thumbnail_display__() self.__add_buttons__() t.destroy() ttk.Button(frame, text="Explore results using existing expert annotations", command = lambda : setup(True)).grid(column=1, row=2) ttk.Button(frame, text="Explore and create gold standard on the fly", command = lambda : setup(False)).grid(column=1, row=3) t.lift(self.root) # self.outputButtons() self.root.mainloop()
Example #22
Source File: antifier.py From antifier with MIT License | 5 votes |
def PowerFactor_Window(self): self.PowerFactor_Window = Tkinter.Toplevel(self.master) self.app = PowerFactor_Window(self.PowerFactor_Window)
Example #23
Source File: guiClass.py From Video-Downloader with GNU General Public License v2.0 | 5 votes |
def __configPanel (self) : self.slave = Tkinter.Toplevel(); self.slave.title("Config") self.slave.resizable(width = 'false', height = 'false') l1 = Tkinter.Label(self.slave, text = '下载目录:') l1.grid(row = 0) self.filePath = Tkinter.StringVar() self.filePath.set(self.cfg['path']) e1 = Tkinter.Entry(self.slave, textvariable = self.filePath) e1.grid(row = 0, column = 1, columnspan = 3) b1 = Tkinter.Button(self.slave, text = '选择', command = self.__chooseCfgFolder) b1.grid(row = 0, column = 4, sticky = 'e') l2 = Tkinter.Label(self.slave, text = '检查更新:') l2.grid(row = 1) self.chkUpdateTime = Tkinter.IntVar() self.chkUpdateTime.set(int(self.cfg['udrate'])) r1 = Tkinter.Radiobutton(self.slave, text="每天", variable=self.chkUpdateTime, value=1) r1.grid(row = 1, column = 1, sticky = 'e') r2 = Tkinter.Radiobutton(self.slave, text="每周", variable=self.chkUpdateTime, value=2) r2.grid(row = 1, column = 2, sticky = 'e') r3 = Tkinter.Radiobutton(self.slave, text="每月", variable=self.chkUpdateTime, value=3) r3.grid(row = 1, column = 3, sticky = 'e') b2 = Tkinter.Button(self.slave, text = '更新', command = self.__setConfig) b2.grid(row = 2, column = 1, sticky = 'e') b3 = Tkinter.Button(self.slave, text = '取消', command = self.slave.destroy) b3.grid(row = 2, column = 2, sticky = 'e')
Example #24
Source File: chartparser_app.py From luscan-devel with GNU General Public License v2.0 | 5 votes |
def __init__(self, parent, chart, grammar, toplevel=True): self._chart = chart self._grammar = grammar self._trees = [] self._y = 10 self._treewidgets = [] self._selection = None self._selectbox = None if toplevel: self._root = Tkinter.Toplevel(parent) self._root.title('Chart Parser Application: Results') self._root.bind('<Control-q>', self.destroy) else: self._root = Tkinter.Frame(parent) # Buttons if toplevel: buttons = Tkinter.Frame(self._root) buttons.pack(side='bottom', expand=0, fill='x') Tkinter.Button(buttons, text='Quit', command=self.destroy).pack(side='right') Tkinter.Button(buttons, text='Print All', command=self.print_all).pack(side='left') Tkinter.Button(buttons, text='Print Selection', command=self.print_selection).pack(side='left') # Canvas frame. self._cframe = CanvasFrame(self._root, closeenough=20) self._cframe.pack(side='top', expand=1, fill='both') # Initial update self.update()
Example #25
Source File: chartparser_app.py From luscan-devel with GNU General Public License v2.0 | 5 votes |
def __init__(self, parent, chart, toplevel=True, title='Chart Matrix', show_numedges=False): self._chart = chart self._cells = [] self._marks = [] self._selected_cell = None if toplevel: self._root = Tkinter.Toplevel(parent) self._root.title(title) self._root.bind('<Control-q>', self.destroy) self._init_quit(self._root) else: self._root = Tkinter.Frame(parent) self._init_matrix(self._root) self._init_list(self._root) if show_numedges: self._init_numedges(self._root) else: self._numedges_label = None self._callbacks = {} self._num_edges = 0 self.draw()
Example #26
Source File: beam_patterning.py From Structural-Engineering with BSD 3-Clause "New" or "Revised" License | 5 votes |
def res_window(self): self.newWindow = tk.Toplevel(self.master) self.res_app = Results_window(self.newWindow)
Example #27
Source File: gui.py From snn_toolbox with MIT License | 5 votes |
def draw_canvas(self): """Draw canvas figure.""" # Create figure with subplots, a canvas to hold them, and add # matplotlib navigation toolbar. if self.layer_to_plot.get() is '': return if hasattr(self, 'plot_container') \ and not self.settings['open_new'].get() \ and not self.is_plot_container_destroyed: self.plot_container.wm_withdraw() self.plot_container = tk.Toplevel(bg='white') self.plot_container.geometry('1920x1080') self.is_plot_container_destroyed = False self.plot_container.wm_title('Results from simulation run {}'.format( self.selected_plots_dir.get())) self.plot_container.protocol('WM_DELETE_WINDOW', self.close_window) tk.Button(self.plot_container, text='Close Window', command=self.close_window).pack() f = plt.figure(figsize=(30, 15)) f.subplots_adjust(left=0.01, bottom=0.05, right=0.99, top=0.99, wspace=0.01, hspace=0.01) num_rows = 3 num_cols = 5 gs = gridspec.GridSpec(num_rows, num_cols) self.a = [plt.subplot(gs[i, 0:-2]) for i in range(3)] self.a += [plt.subplot(gs[i, -2]) for i in range(3)] self.a += [plt.subplot(gs[i, -1]) for i in range(3)] self.canvas = FigureCanvasTkAgg(f, self.plot_container) graph_widget = self.canvas.get_tk_widget() graph_widget.pack(side='top', fill='both', expand=True) self.toolbar = NavigationToolbar2TkAgg(self.canvas, graph_widget)
Example #28
Source File: gui.py From omg-tools with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self, master, text): self.top=tk.Toplevel(master) self.label=tk.Label(self.top,text=text) self.label.pack() self.entry=tk.Entry(self.top) self.entry.pack() self.button=tk.Button(self.top,text='Ok',command=self.cleanup) self.button.pack()
Example #29
Source File: antifier.py From antifier with MIT License | 5 votes |
def HeadUnit_window(self): self.HeadUnitWindow = Tkinter.Toplevel(self.master) self.app = HeadUnit_Window(self.HeadUnitWindow)
Example #30
Source File: viewer.py From networkx_viewer with GNU General Public License v3.0 | 5 votes |
def destroy(self): res = self.entry.get() if res not in self.posibilities: res = None self.result = res tk.Toplevel.destroy(self)