當前位置: 首頁>>代碼示例>>Python>>正文


Python Tkinter.Toplevel方法代碼示例

本文整理匯總了Python中Tkinter.Toplevel方法的典型用法代碼示例。如果您正苦於以下問題:Python Tkinter.Toplevel方法的具體用法?Python Tkinter.Toplevel怎麽用?Python Tkinter.Toplevel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Tkinter的用法示例。


在下文中一共展示了Tkinter.Toplevel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Toplevel [as 別名]
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) 
開發者ID:jsexauer,項目名稱:networkx_viewer,代碼行數:24,代碼來源:viewer.py

示例2: showtip

# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Toplevel [as 別名]
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) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:24,代碼來源:backend_tkagg.py

示例3: _color_delegator

# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Toplevel [as 別名]
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) 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:19,代碼來源:ColorDelegator.py

示例4: _dyn_option_menu

# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Toplevel [as 別名]
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() 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:20,代碼來源:dynOptionMenuWidget.py

示例5: _calltip_window

# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Toplevel [as 別名]
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() 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:24,代碼來源:CallTipWindow.py

示例6: _show

# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Toplevel [as 別名]
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() 
開發者ID:tp4a,項目名稱:teleport,代碼行數:20,代碼來源:ImageTk.py

示例7: edit_experimental_settings

# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Toplevel [as 別名]
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) 
開發者ID:NeuromorphicProcessorProject,項目名稱:snn_toolbox,代碼行數:22,代碼來源:gui.py

示例8: example1

# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Toplevel [as 別名]
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() 
開發者ID:j4321,項目名稱:tkcalendar,代碼行數:21,代碼來源:__main__.py

示例9: display

# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Toplevel [as 別名]
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) 
開發者ID:nccgroup,項目名稱:Splunking-Crime,代碼行數:19,代碼來源:EditorWindow.py

示例10: mainloop

# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Toplevel [as 別名]
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...") 
開發者ID:jahuth,項目名稱:convis,代碼行數:26,代碼來源:streams.py

示例11: _show

# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Toplevel [as 別名]
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() 
開發者ID:cineuse,項目名稱:CNCGToolKit,代碼行數:19,代碼來源:ImageTk.py

示例12: destroy

# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Toplevel [as 別名]
def destroy(self):
        res = self.entry.get()
        if res not in self.posibilities:
            res = None
        self.result = res
        tk.Toplevel.destroy(self) 
開發者ID:jsexauer,項目名稱:networkx_viewer,代碼行數:8,代碼來源:viewer.py

示例13: __init__

# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Toplevel [as 別名]
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() 
開發者ID:rafasashi,項目名稱:razzy-spinner,代碼行數:30,代碼來源:chart.py

示例14: __init__

# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Toplevel [as 別名]
def __init__(self, imagefileName, title):
		self._root = Tkinter.Toplevel()
		self._root.title(title + ' (' + imagefileName + ')')
		self.image = Tkinter.PhotoImage("LGraph",file=imagefileName)

		Tkinter.Label(self._root, image=self.image).pack(side='top',fill='x')
		# self._root.mainloop() 
開發者ID:rafasashi,項目名稱:razzy-spinner,代碼行數:9,代碼來源:kimmo.py

示例15: _adjust_lens1

# 需要導入模塊: import Tkinter [as 別名]
# 或者: from Tkinter import Toplevel [as 別名]
def _adjust_lens1(self):
        self._destroy(self.win_lens1)
        try:
            self.win_lens1 = tk.Toplevel(self.parent)
            FisheyeAlignmentGUI(self.win_lens1, self.img1.get(), self.lens1)
        except IOError:
            self._destroy(self.win_lens1)
            tkMessageBox.showerror('Error', 'Unable to read image file #1.')
        except:
            self._destroy(self.win_lens1)
            tkMessageBox.showerror('Dialog creation error', traceback.format_exc()) 
開發者ID:ooterness,項目名稱:DualFisheye,代碼行數:13,代碼來源:fisheye.py


注:本文中的Tkinter.Toplevel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。