Python tkinter.ttk 模块,Button() 实例源码

我们从Python开源项目中,提取了以下49个代码示例,用于说明如何使用tkinter.ttk.Button()

项目:Quiver    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, window, *args, **kwargs):
        ttk.Treeview.__init__(self, parent, selectmode="browse", columns=["", ""], *args, **kwargs)
        self.parent = window

        self.heading("#0", text="Resource File")
        self.heading("#1", text="Files")
        self.column("#1", anchor="e", width=50, stretch=False)
        self.heading("#2", text="File Extension")
        self.column("#2", width=100, stretch=False)

        self.widget_menu_tree = tk.Menu(self)
        self.bind("<Button-3>", self.show_menu)

        self.widget_menu_tree.add_command(label="Open", command=self.parent.open_file)
        self.widget_menu_tree.add_command(label="Edit", state="disabled")
        self.widget_menu_tree.add_separator()
        self.widget_menu_tree.add_command(label="Delete", command=self.parent.cmd.tree_delete_selected)
项目:python-tagger    作者:Bilingual-Annotation-Task-Force    | 项目源码 | 文件源码
def _create_widgets(self):
        # Gold standard data
        self.gold_path_label = ttk.Label(text="Gold Standard:")
        self.gold_path_entry = ttk.Entry(textvariable=self.gold_path)
        self.gold_path_filebutton = ttk.Button(text="...", command=self.findgoldfile)
        # Training data for language 1
        self.lang1_train_path_label = ttk.Label(text="Language 1 Training Data:")
        self.lang1_train_path_entry = ttk.Entry(textvariable=self.lang1_train_path)
        self.lang1_train_path_filebutton = ttk.Button(text="...", command=self.findlang1trainfile)
        # Training data for language 2
        self.lang2_train_path_label = ttk.Label(text="Language 2 Training Data:")
        self.lang2_train_path_entry = ttk.Entry(textvariable=self.lang2_train_path)
        self.lang2_train_path_filebutton = ttk.Button(text="...", command=self.findlang2trainfile)
        # Examination
        self.examine_button = ttk.Button(text="Examine!", command=self.launch_main)
        # Redirected ouput
        self.output_frame = ttk.Frame()
        self.output = tk.Text(master=self.output_frame)
        self.output_scroll = ttk.Scrollbar(self.output_frame)
        self.output.configure(yscrollcommand=self.output_scroll.set)
        self.output_scroll.configure(command=self.output.yview)

        self.redirected = Redirector(self.output)
项目:synthesizer    作者:irmen    | 项目源码 | 文件源码
def __init__(self, app, master):
        super().__init__(master, text="Playlist", padding=4)
        self.app = app
        bf = ttk.Frame(self)
        ttk.Button(bf, text="Move to Top", width=11, command=self.do_to_top).pack()
        ttk.Button(bf, text="Move Up", width=11, command=self.do_move_up).pack()
        ttk.Button(bf, text="Move Down", width=11, command=self.do_move_down).pack()
        ttk.Button(bf, text="Remove", width=11, command=self.do_remove).pack()
        bf.pack(side=tk.LEFT, padx=4)
        sf = ttk.Frame(self)
        cols = [("title", 300), ("artist", 180), ("album", 180), ("length", 60)]
        self.listTree = ttk.Treeview(sf, columns=[col for col, _ in cols], height=10, show="headings")
        vsb = ttk.Scrollbar(orient="vertical", command=self.listTree.yview)
        self.listTree.configure(yscrollcommand=vsb.set)
        self.listTree.grid(column=1, row=0, sticky=tk.NSEW, in_=sf)
        vsb.grid(column=0, row=0, sticky=tk.NS, in_=sf)
        for col, colwidth in cols:
            self.listTree.heading(col, text=col.title())
            self.listTree.column(col, width=colwidth)
        sf.grid_columnconfigure(0, weight=1)
        sf.grid_rowconfigure(0, weight=1)
        sf.pack(side=tk.LEFT, padx=4)
项目:PyTasks    作者:TheHirschfield    | 项目源码 | 文件源码
def onNewTask(self):
        print("This Will Allow The User To Create An Task.")

        self.taskWindows = Toplevel(self)
        self.taskWindows.wm_title("New Task")

        Label(self.taskWindows, text="Task Name").grid(row=0)
        Label(self.taskWindows, text="Task Day:").grid(row=1)
        Label(self.taskWindows, text="Task Month:").grid(row=2)
        Label(self.taskWindows, text="Task Year:").grid(row=3)

        self.taskGrid1 = Entry(self.taskWindows)
        self.taskGrid2 = Entry(self.taskWindows)
        self.taskGrid3 = Entry(self.taskWindows)
        self.taskGrid4 = Entry(self.taskWindows)

        self.taskGrid1.grid(row=0, column=1)
        self.taskGrid2.grid(row=1, column=1)
        self.taskGrid3.grid(row=2, column=1)
        self.taskGrid4.grid(row=3, column=1)

        Button(self.taskWindows, text='Add', command=self.taskWindowAdd).grid(row=5, column=0, sticky=W, pady=4)
        Button(self.taskWindows, text='Cancel', command=self.taskWindowClose).grid(row=5, column=1, sticky=W, pady=4)
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def tkinterApp():
    import tkinter as tk
    from tkinter import ttk
    win = tk.Tk()    
    win.title("Python GUI")
    aLabel = ttk.Label(win, text="A Label")
    aLabel.grid(column=0, row=0)    
    ttk.Label(win, text="Enter a name:").grid(column=0, row=0)
    name = tk.StringVar()
    nameEntered = ttk.Entry(win, width=12, textvariable=name)
    nameEntered.grid(column=0, row=1)
    nameEntered.focus() 

    def buttonCallback():
        action.configure(text='Hello ' + name.get())
    action = ttk.Button(win, text="Print", command=buttonCallback) 
    action.grid(column=2, row=1)
    win.mainloop()

#==================================================================
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def display_tab3():
    monty3 = ttk.LabelFrame(display_area, text=' New Features ')
    monty3.grid(column=0, row=0, padx=8, pady=4)

    # Adding more Feature Buttons
    startRow = 4
    for idx in range(24):
        if idx < 2:
            colIdx = idx
            col = colIdx
        else:
            col += 1
        if not idx % 3: 
            startRow += 1
            col = 0

        b = ttk.Button(monty3, text="Feature " + str(idx + 1))   
        b.grid(column=col, row=startRow)    

    # Add some space around each label
    for child in monty3.winfo_children(): 
        child.grid_configure(padx=8) 

#------------------------------------------
项目:Quiver    作者:DeflatedPickle    | 项目源码 | 文件源码
def body(self, master):
        TreeDialog.body(self, master)

        frame = ttk.Frame(master)
        frame.pack(side="right")

        frame_one = ttk.Frame(frame)
        frame_one.pack(pady=5)

        add = ttk.Button(frame_one, text="Add Pack")
        add.pack()

        remove = ttk.Button(frame_one, text="Remove Pack")
        remove.pack()

        frame_two = ttk.Frame(frame)
        frame_two.pack(pady=5)

        enable = ttk.Button(frame_two, text="Enable Pack")
        enable.pack()

        disable = ttk.Button(frame_two, text="Disable Pack")
        disable.pack()
项目:pkinter    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, title="", title_command=None, info="", info_command=None, background="SystemButtonFace", *args):
        ttk.Frame.__init__(self, parent, *args)
        self.parent = parent
        self._title = title
        self._title_command = title_command
        self._info = info
        self._info_command = info_command
        self._background = background

        self.columnconfigure(1, weight=1)

        style = ttk.Style()
        style.configure("InfoBar.Toolbutton", background=self._background)
        style.configure("InfoClose.InfoBar.Toolbutton", anchor="center")

        if self._title != "":
            self._title_button = ttk.Button(self, text=self._title, style="InfoBar.Toolbutton", command=self._title_command)
            self._title_button.grid(row=0, column=0)

        self._info_button = ttk.Button(self, text=self._info, style="InfoBar.Toolbutton", command=self._info_command)
        self._info_button.grid(row=0, column=1, sticky="we")

        self._close_button = ttk.Button(self, text="x", width=2, style="InfoClose.InfoBar.Toolbutton", command=self.close)
        self._close_button.grid(row=0, column=2)
项目:twitch-bits-info    作者:floweb    | 项目源码 | 文件源码
def __init__(self, parent=None):
        tk.Tk.__init__(self, parent)
        self.parent = parent

        self.log_text = tkst.ScrolledText(self, state=tk.DISABLED)
        self.log_text.configure(font='TkFixedFont')
        self.log_text.pack(side=tk.LEFT, padx=5, pady=5)

        self.start_button = ttk.Button(parent, text='Start ConsoleMini', state=tk.NORMAL,
                                       command=self.start_twitch_bits_info)
        self.start_button.pack(side=tk.TOP, padx=12, pady=12)

        self.stop_button = ttk.Button(parent, text='Stop ConsoleMini', state=tk.DISABLED,
                                      command=self.stop_twitch_bits_info)
        self.stop_button.pack(side=tk.TOP, padx=12, pady=12)

        self.update_button = ttk.Button(parent, text='Manual update JSON', state=tk.DISABLED,
                                        command=self.manual_update_json)
        self.update_button.pack(side=tk.TOP, padx=12, pady=12)
项目:ankimaker    作者:carllacan    | 项目源码 | 文件源码
def init_frame(self):
        self.dbfile = ''

        self.file_entry = ttk.Entry(self, width=25)
        self.file_entry.grid(column=0, row=1, columnspan=2, sticky='W')

        self.selecdb_button = ttk.Button(self, text='Browse',
                                      command=self.select_file)
        self.selecdb_button.grid(column=2, row=1, sticky='E')

        self.usage_check = CheckButton(self)
        self.usage_check.grid(column = 0, row = 2, sticky='E')
        self.usage_label = ttk.Label(self, text='Load also usage sentences')
        self.usage_label.grid(column = 1, row = 2, sticky='W')

        self.load_button = ttk.Button(self, text='Load words',
                                      command=self.load_words)
        self.load_button.grid(column = 2, row = 2, sticky='W')
项目:ankimaker    作者:carllacan    | 项目源码 | 文件源码
def init_frame(self):
        ttk.Label(self, text='App id').grid(column=0, row=0)
        self.appid_entry = ttk.Entry(self, width=30)
        self.appid_entry.grid(column=1, row = 0)

        ttk.Label(self, text='App key').grid(column=0, row=1)
        self.keyid_entry = ttk.Entry(self, width=30)
        self.keyid_entry.grid(column=1, row = 1)

        self.load_button = ttk.Button(self, text='Load definitions from OED',
                                      command=self.load_info)
        self.load_button.grid(column=0, row=2, columnspan = 2, rowspan = 2)
#        self.load_button.state(['disabled'])

        try: # for lazines I store my OED credentials in a file
            secrets = open('secrets')
            self.appid_entry.insert(0, secrets.readline()[:-1])
            self.keyid_entry.insert(0, secrets.readline()[:-1])
            secrets.close()
        except:
            pass
项目:copycat    作者:LSaldyt    | 项目源码 | 文件源码
def __init__(self, parent, *args, **kwargs):
        GridFrame.__init__(self, parent, *args, **kwargs)

        self.paused = True
        self.steps  = 0
        self.go     = False

        self.playbutton = ttk.Button(self, text='Play', command=lambda : self.toggle())
        self.add(self.playbutton, 0, 0)

        self.stepbutton = ttk.Button(self, text='Step', command=lambda : self.step())
        self.add(self.stepbutton, 1, 0)

        self.entry = Entry(self)
        self.add(self.entry, 0, 1, xspan=2)

        self.gobutton = ttk.Button(self, text='Go', command=lambda : self.set_go())
        self.add(self.gobutton, 0, 2, xspan=2)
项目:pyktrader2    作者:harveywwu    | 项目源码 | 文件源码
def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        label = tk.Label(self, text="Graph Page!", font=LARGE_FONT)
        label.pack(pady=10,padx=10)

        button1 = ttk.Button(self, text="Back to Home",
                            command=lambda: controller.show_frame(StartPage))
        button1.pack()

        canvas = FigureCanvasTkAgg(f, self)
        canvas.show()
        canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)

        toolbar = NavigationToolbar2TkAgg(canvas, self)
        toolbar.update()
        canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
项目:Tkinter-By-Example    作者:Dvlv    | 项目源码 | 文件源码
def __init__(self, master):
        super().__init__()

        self.master = master

        self.title("Add new Language")
        self.geometry("300x150")

        self.name_label = ttk.Label(self, text="Language Name", anchor="center")
        self.name_entry = ttk.Entry(self)
        self.code_label = ttk.Label(self, text="Language Code", anchor="center")
        self.code_entry = ttk.Entry(self)
        self.submit_button = ttk.Button(self, text="Submit", command=self.submit)

        self.name_label.pack(fill=tk.BOTH, expand=1)
        self.name_entry.pack(fill=tk.BOTH)
        self.code_label.pack(fill=tk.BOTH, expand=1)
        self.code_entry.pack(fill=tk.BOTH, expand=1)
        self.submit_button.pack(fill=tk.X)
项目:Colony    作者:DeflatedPickle    | 项目源码 | 文件源码
def __init__(self, parent, *args, **kwargs):
        tk.Toplevel.__init__(self, parent, *args, **kwargs)
        self.parent = parent
        self.resizable(False, False)
        self.geometry("200x250")
        self.transient(parent)
        self.grab_set()

        self.current_row = 0

        self.frame_widget = ttk.Frame(self)
        self.frame_widget.pack(fill="both", expand=True)
        self.frame_widget.rowconfigure(0, weight=1)
        self.frame_widget.columnconfigure(0, weight=1)

        self.frame_buttons = ttk.Frame(self)
        self.frame_buttons.pack(fill="x")
        ttk.Button(self.frame_buttons, text="Close", command=self.close).pack(side="left")

        self.parent.bind("<Configure>", self.center)
        self.protocol("WM_DELETE_WINDOW", self.close)

        self.center()
项目:quill    作者:DeflatedPickle    | 项目源码 | 文件源码
def insert_extending_text(self, what: str="", extend: str="", fill_line: bool=False, index: int or str="end", command=None, *args):
        """Inserts a string of text that can be extended."""
        tag = "Extend-{}-{}:{}".format(re.sub("[^0-9a-zA-Z]+", "", extend), "normal", self.id_current_extend)
        tag2 = "Extend-{}-{}:{}".format(re.sub("[^0-9a-zA-Z]+", "", extend), "extend", self.id_current_extend)
        self.text.tag_configure(tag, foreground=self.colour_extend_on, elide=False)
        self.text.tag_configure(tag2, foreground=self.colour_extend_off, elide=True)
        self.text.insert(index, what + "\n" if fill_line else what, tag)
        self.text.insert(index, extend + "\n" if fill_line else extend, tag2)

        self.unbind_tag(tag, release=True, both=True)

        self.text.tag_bind(tag, "<ButtonRelease-1>", command, "+")
        self.text.tag_bind(tag, "<Button-1>", lambda *args: self.toggle_extend(tag, tag2), "+")

        self.bind_cursor(tag)
        self.bind_background(tag)

        self.id_current_extend += 1
项目:quill    作者:DeflatedPickle    | 项目源码 | 文件源码
def insert_checkbutton(self, what: str="", variable: tk.BooleanVar=None, fill_line: bool=True, index: int or str="end", command=None, *args):
        """Insert a checkbutton into the game."""
        tag = "Check-{}:{}".format(re.sub("[^0-9a-zA-Z]+", "", what), self.id_current_check)
        if variable.get():
            self.text.tag_configure(tag, foreground=self.colour_check_on)
        elif not variable.get():
            self.text.tag_configure(tag, foreground=self.colour_check_off)
        self.text.insert(index, what + "\n" if fill_line else what, tag)

        self.unbind_tag(tag)

        self.text.tag_bind(tag, "<Button-1>", command, "+")
        self.text.tag_bind(tag, "<Button-1>", lambda *args: self.toggle_check(variable, tag), "+")

        self.bind_cursor(tag)
        self.bind_background(tag)

        self.id_current_check += 1
项目:quill    作者:DeflatedPickle    | 项目源码 | 文件源码
def insert_radiobutton(self, what: str="", variable: tk.IntVar=None, value: int=0, fill_line: bool=True, index: int or str="end", command=None, *args):
        """Inserts a radiobutton into the game."""
        tag = "Radio-{}-{}:{}".format(re.sub("[^0-9a-zA-Z]+", "", str(variable)), str(value), self.id_current_radio)
        if variable.get() == value:
            self.text.tag_configure(tag, foreground=self.colour_radio_on)
        elif variable.get() != value:
            self.text.tag_configure(tag, foreground=self.colour_radio_off)
        self.text.insert(index, what + "\n" if fill_line else what, tag)

        self.unbind_tag(tag, release=True, both=True)

        self.text.tag_bind(tag, "<ButtonRelease-1>", command, "+")
        self.text.tag_bind(tag, "<Button-1>", lambda *args: self.toggle_radio(variable, value, tag), "+")

        self.bind_cursor(tag)
        self.bind_background(tag)

        self.id_current_radio += 1
项目:quill    作者:DeflatedPickle    | 项目源码 | 文件源码
def insert_trigger(self, what: str="", fill_line: bool=False, index: int or str="end", command=None, *args):
        """Inserts a trigger into the game."""
        tag = "Trigger-{}:{}".format(re.sub("[^0-9a-zA-Z]+", "", what), self.id_current_trigger)
        self.text.tag_configure(tag, foreground=self.colour_trigger_on)
        self.text.insert(index, what + "\n" if fill_line else what, tag)

        self.unbind_tag(tag)

        self.text.tag_bind(tag, "<Button-1>", command, "+")
        self.text.tag_bind(tag, "<Button-1>", lambda *args: self.toggle_trigger(tag), "+")

        self.bind_cursor(tag)
        self.bind_background(tag)

        self.id_current_trigger += 1

        return tag
项目:BioDataSorter    作者:BioDataSorter    | 项目源码 | 文件源码
def __init__(self, master, *args, **kwargs):
        super().__init__(master, *args, **kwargs)
        self.title("Convert File")
        self.master = master

        self.file_opt = options = {}
        options['defaultextension'] = '.txt'
        options['filetypes'] = [('text files', '.txt')]
        options['initialdir'] = "C:\\Users\\%s\\" % getpass.getuser()
        options['parent'] = master
        options['title'] = "Choose a file"

        self.grid_columnconfigure(1, weight=1)
        msg = Label(self, text="Convert tab delineated .txt to .xlsx.")
        msg.grid(row=0, columnspan=3, pady=(10, 4), padx=5)
        lab = Label(self, text="Text file: ")
        lab.grid(row=1, column=0, padx=5)

        # this stores the displayed version of the filename
        self.v_display = StringVar()
        b1 = ttk.Button(self, text="Browse...", command=self.askopenfilename)
        b1.grid(row=1, column=1, padx=5)
        self.geometry('190x80+300+300')
项目:BioDataSorter    作者:BioDataSorter    | 项目源码 | 文件源码
def button_from_label(self, text, image_url, cmd, status):
        image = Image.open(image_url)
        image = image.resize((30, 30), Image.ANTIALIAS)
        photo = ImageTk.PhotoImage(image)
        btn = Label(self,
                    text=text,
                    image=photo,
                    compound=TOP,
                    width=70,
                    bg=NOTEBOOK_COLOR,
                    cursor='hand2')
        btn.bind('<Button-1>', cmd)
        btn.bind('<Enter>', lambda e: (btn.config(bg='light cyan'),
                                       self.controller.status_bar.set(status)))
        btn.bind('<Leave>', lambda e:
                 (btn.config(bg=NOTEBOOK_COLOR),
                  self.controller.status_bar.set('Ready')))
        btn.bind('<ButtonRelease-1>', lambda e: btn.config(bg='light cyan'))
        return btn, photo
项目:PyTouch    作者:mNisblee    | 项目源码 | 文件源码
def __init__(self, master, **kwargs):
        super().__init__(master, **kwargs)

        self.content_frame = ttk.Frame(self)
        self.lb_title = ttk.Label(self.content_frame, text='Lesson paused')
        self.button_frame = ttk.Frame(self.content_frame)
        self.bt_continue = ttk.Button(self.button_frame, text='Continue', default='active', command=self.on_continue)
        self.bt_restart = ttk.Button(self.button_frame, text='Restart')
        self.bt_abort = ttk.Button(self.button_frame, text='Abort')

        self.content_frame.grid(column=0, row=0)
        self.lb_title.grid(column=0, row=0, pady=3)
        self.button_frame.grid(column=0, row=1, pady=10)
        self.bt_continue.grid(column=0, row=1, pady=3)
        self.bt_restart.grid(column=0, row=2, pady=3)
        self.bt_abort.grid(column=0, row=3, pady=3)

        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        self.focus_set()
项目:IC-Inventory    作者:tjschweizer    | 项目源码 | 文件源码
def invalidInventoryPopup(self, msg, *mainFuncs):
        """
        Creates a popupwindow and binds the button to multiple functions

        :param msg: Text message displayed in the popupwindow
        :type msg: str
        :param mainFuncs: List of functions to be run when the user clicks OK
        """
        window = Tk()
        window.wm_title('Invalid Inventory File')

        message = ttk.Label(window, text=msg)
        message.grid(row=0, column=0, columnspan=2, pady=10, padx=10, sticky=tkinter.N + tkinter.S)
        okButton = ttk.Button(window, text="OK", command=lambda: self.combine_funcs(window.destroy(), window.quit()))
        okButton.grid(row=1, column=1, sticky=tkinter.N + tkinter.S)
        window.mainloop()
项目:LadderiLogical    作者:mikadam    | 项目源码 | 文件源码
def __init__(self,root,app):
        ttk.Frame.__init__(self, root)
        self.root=root
        self.app=app

        self.tool="select"

        self.select=ttk.Button(master=self,text="Select",command=lambda:self.change_tool("select"))
        self.horizontal=ttk.Button(master=self,text="Horizontal",command=lambda:self.change_tool("horizontal"))
        self.hswitch=ttk.Button(master=self,text="HSwitch",command=lambda:self.change_tool("hswitch"))
        self.delete=ttk.Button(master=self,text="Delete",command=lambda:self.change_tool("delete"))
        self.flag=ttk.Button(master=self,text="Flag",command=lambda:self.change_tool("flag"))
        self.auto=ttk.Button(master=self,text="Auto",command=lambda:self.change_tool("auto"))


        self.select.grid(row=0,column=0)
        self.auto.grid(row=0,column=1)
        self.delete.grid(row=0,column=2)
        self.horizontal.grid(row=0,column=3)
        self.hswitch.grid(row=0,column=4)
        self.flag.grid(row=0,column=5)
项目:pyGISS    作者:afourmy    | 项目源码 | 文件源码
def __init__(self, controller):
        super().__init__(controller, bg='white', width=1300, height=800)
        self.controller = controller
        self.node_id_to_node = {}
        self.drag_item = None
        self.start_position = [None]*2
        self.start_pos_main_node = [None]*2
        self.dict_start_position = {}
        self.selected_nodes = set()
        self.filepath = None
        self.proj = 'Mercator'
        self.ratio, self.offset = 1, (0, 0)
        self.bind('<MouseWheel>', self.zoomer)
        self.bind('<Button-4>', lambda e: self.zoomer(e, 1.3))
        self.bind('<Button-5>', lambda e: self.zoomer(e, 0.7))
        self.bind('<ButtonPress-3>', lambda e: self.scan_mark(e.x, e.y))
        self.bind('<B3-Motion>', lambda e: self.scan_dragto(e.x, e.y, gain=1))
        self.bind('<Enter>', self.drag_and_drop, add='+')
        self.bind('<ButtonPress-1>', self.start_point_select_objects, add='+')
        self.bind('<B1-Motion>', self.rectangle_drawing)
        self.bind('<ButtonRelease-1>', self.end_point_select_nodes, add='+')
        self.tag_bind('node', '<Button-1>', self.find_closest_node)
        self.tag_bind('node', '<B1-Motion>', self.node_motion)
项目:pyTrack    作者:clamytoe    | 项目源码 | 文件源码
def setup_tab2(tab):
    # new frame
    new_frame = ttk.LabelFrame(tab, text='New Project Name')
    new_frame.grid(columnspan=2, row=0, padx=5, pady=5, sticky='ew')

    # New Project
    name = tk.StringVar
    name_entered = ttk.Entry(new_frame, width=19, textvariable=name)
    name_entered.grid(column=0, row=0, padx=6, pady=5)
    name_entered.focus()

    # spacer
    spacer_label = ttk.Label(new_frame, text='')
    spacer_label.grid(columnspan=2, row=1, padx=5, pady=5)

    # add button and commands
    def add_command():
        add_project(name_entered.get())
        spacer_label.configure(text='Project was added!', foreground='green')
        name_entered.delete(0, "end")
        setup_tab1(TAB_1)
        TAB_1.update()

    add_button = ttk.Button(tab, text='Add New Project', command=add_command)
    add_button.grid(columnspan=2, row=3, pady=5)
项目:sorter    作者:giantas    | 项目源码 | 文件源码
def _create_canvas(self, window):
        # Configure canvas
        canvas = Canvas(window)
        hsb = ttk.Scrollbar(window, orient="h", command=canvas.xview)
        vsb = ttk.Scrollbar(window, orient="v", command=canvas.yview)
        canvas.configure(yscrollcommand=vsb.set, xscrollcommand=hsb.set)

        canvas.grid(sticky="nsew")
        hsb.grid(row=1, column=0, stick="ew")
        vsb.grid(row=0, column=1, sticky="ns")

        window.grid_rowconfigure(0, weight=1)
        window.grid_columnconfigure(0, weight=1)

        canvas.configure(scrollregion=(0, 0, 1250, 10000))
        canvas.bind('<Configure>', lambda event,
                    canvas=canvas: self._resize_canvas(event, canvas))
        canvas.bind_all("<Button-4>", lambda event, count=-1,
                        canvas=canvas: self._on_mousewheel(event, canvas, count))
        canvas.bind_all("<Button-5>", lambda event, count=1,
                        canvas=canvas: self._on_mousewheel(event, canvas, count))
        canvas.bind_all("<MouseWheel>", lambda event, count=1,
                        canvas=canvas: self._on_mousewheel(event, canvas, count))

        return canvas
项目:synthesizer    作者:irmen    | 项目源码 | 文件源码
def __init__(self, app, master):
        super().__init__(master, text="Effects/Samples - shift+click to assign sample", padding=4)
        self.app = app
        self.effects = {num: None for num in range(16)}
        f = ttk.Frame(self)
        self.buttons = []
        for i in range(1, 9):
            b = ttk.Button(f, text="# {:d}".format(i), width=14, state=tk.DISABLED)
            b.bind("<ButtonRelease>", self.do_button_release)
            b.effect_nr = i
            b.pack(side=tk.LEFT)
            self.buttons.append(b)
        f.pack()
        f = ttk.Frame(self)
        for i in range(9, 17):
            b = ttk.Button(f, text="# {:d}".format(i), width=14, state=tk.DISABLED)
            b.bind("<ButtonRelease>", self.do_button_release)
            b.effect_nr = i
            b. pack(side=tk.LEFT)
            self.buttons.append(b)
        f.pack()
        self.after(2000, lambda: Pyro4.Future(self.load_settings)(True))
项目:PyTasks    作者:TheHirschfield    | 项目源码 | 文件源码
def calenderStyleWidget(self):
        style = ttk.Style(self.master)
        styleArrowLayout = lambda dir: (
            [('Button.focus', {'children': [('Button.%sarrow' % dir, None)]})]
        )
        style.layout('L.TButton', styleArrowLayout('left'))
        style.layout('R.TButton', styleArrowLayout('right'))
        style.configure('Calendar.Treeview', rowheight=40)
项目:PyTasks    作者:TheHirschfield    | 项目源码 | 文件源码
def calenderPlaceWidget(self):
        #Header Frame
        calenderFrame = ttk.Frame(self)
        leftMonthChangeButton = ttk.Button(calenderFrame, style='L.TButton', command=self.setPreviousMonth)
        rightMonthChangeButton = ttk.Button(calenderFrame, style='R.TButton', command=self.setNextMonth)
        self.calenderHeader = ttk.Label(calenderFrame, width=15, anchor='center')
        self.calenderMainView = ttk.Treeview(show='', selectmode='none', height=7, style='Calendar.Treeview')

        #Pack Header
        calenderFrame.pack(in_=self, side='top', pady=4, anchor='center')
        leftMonthChangeButton.grid(in_=calenderFrame)
        self.calenderHeader.grid(in_=calenderFrame, column=1, row=0, padx=12)
        rightMonthChangeButton.grid(in_=calenderFrame, column=2, row=0)
        self.calenderMainView.pack(in_=self, fill='x', side='top')
项目:modis    作者:Infraxion    | 项目源码 | 文件源码
def __init__(self, parent):
        """Send messages from the bot

        Args:
            parent:
        """

        super(ChatFrame, self).__init__(parent, padding=8, text="Chat")

        self.channel = tk.StringVar()
        self.message = tk.StringVar()

        self.channel_frame = ttk.Frame(self)
        self.channel_frame.grid(column=0, row=0, sticky="W E")
        self.channel_label = ttk.Label(self.channel_frame, text="Channel ID:")
        self.channel_label.grid(column=0, row=0, sticky="W E")
        self.channel_box = ttk.Entry(self.channel_frame, textvariable=self.channel)
        self.channel_box.grid(column=0, row=1, sticky="W E")
        self.channel_frame.columnconfigure(0, weight=1)

        self.message_frame = ttk.Frame(self)
        self.message_frame.grid(column=0, row=1, pady=8, sticky="W E")
        self.message_label = ttk.Label(self.message_frame, text="Message:")
        self.message_label.grid(column=0, row=0, sticky="W E")
        self.message_box = ttk.Entry(self.message_frame, textvariable=self.message)
        self.message_box.grid(column=0, row=1, sticky="W E")
        self.message_frame.columnconfigure(0, weight=1)

        self.send_button = ttk.Button(self, command=lambda: self.add_current_message(), text="Send")
        self.send_button.grid(column=0, row=2, sticky="W")

        self.columnconfigure(0, weight=1)
项目:modis    作者:Infraxion    | 项目源码 | 文件源码
def __init__(self, parent):
        """
        Create a new UI for the module

        Args:
            parent: A tk or ttk object
        """

        super(ModuleUIFrame, self).__init__(parent)
        self.columnconfigure(0, weight=1)
        self.rowconfigure(1, weight=1)

        # Set default values
        from ....datatools import get_data
        data = get_data()

        # API Frame
        api_frame = ttk.LabelFrame(self, padding=8, text="Google API")
        api_frame.grid(row=0, column=0, sticky="W E N S")
        api_frame.columnconfigure(0, weight=1)
        # Add key fields
        self.google_api_key = tk.StringVar()
        ttk.Label(api_frame, text="Google API Key").grid(column=0, row=0, sticky="W E N S")
        ttk.Entry(api_frame, textvariable=self.google_api_key).grid(
            column=0, row=1, padx=0, pady=4, sticky="W E N S")
        self.soundcloud_client_id = tk.StringVar()
        ttk.Label(api_frame, text="SoundCloud Client ID").grid(column=0, row=2, sticky="W E N S")
        ttk.Entry(api_frame, textvariable=self.soundcloud_client_id).grid(
            column=0, row=3, padx=0, pady=4, sticky="W E N S")
        ttk.Button(api_frame, command=lambda: self.update_keys(), text="Update API Data").grid(
            column=0, row=4, padx=0, pady=4, sticky="W E N S")

        if "google_api_key" in data["discord"]["keys"]:
            self.google_api_key.set(data["discord"]["keys"]["google_api_key"])
        if "soundcloud_client_id" in data["discord"]["keys"]:
            self.soundcloud_client_id.set(data["discord"]["keys"]["soundcloud_client_id"])
项目:modis    作者:Infraxion    | 项目源码 | 文件源码
def add_module(self, module_name, module_ui):
        """
        Adds a module to the list

        Args:
            module_name (str): The name of the module
            module_ui: The function to call to create the module's UI
        """
        m_button = tk.Label(self.module_selection, text=module_name, bg="white", anchor="w")
        m_button.grid(column=0, row=len(self.module_selection.winfo_children()), padx=0, pady=0, sticky="W E N S")

        self.module_buttons[module_name] = m_button
        m_button.bind("<Button-1>", lambda e: self.module_selected(module_name, module_ui))
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def __init__(self):         # Initializer method
        # Create instance
        self.win = tk.Tk()   

        tt.create_ToolTip(self.win, 'Hello GUI')

        # Add a title       
        self.win.title("Python GUI")      
        self.create_widgets()

    # Modified Button Click Function
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def __init__(self):         # Initializer method
        # Create instance
        self.win = tk.Tk()   

        create_ToolTip(self.win, 'Hello GUI')

        # Add a title       
        self.win.title("Python GUI")      
        self.create_widgets()

    # Modified Button Click Function
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def __init__(self):         # Initializer method
        # Create instance
        self.win = tk.Tk()   

        tt.create_ToolTip(self.win, 'Hello GUI')

        # Add a title       
        self.win.title("Python GUI")      
        self.create_widgets()

    # Modified Button Click Function
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def useQueues(self):
        # Now using a class member Queue        
        while True: 
            qItem = self.guiQueue.get()
            print(qItem)
            self.scr.insert(tk.INSERT, qItem + '\n') 

    # Button callback
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def insertQuote(self):
        title = self.bookTitle.get()
        page = self.pageNumber.get()
        quote = self.quote.get(1.0, tk.END)
        print(title)
        print(quote)
        self.mySQL.insertBooks(title, page, quote)     

    # Button callback
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        parent.CreateStatusBar() 
        menu= wx.Menu()
        menu.Append(wx.ID_ABOUT, "About", "wxPython GUI")
        menuBar = wx.MenuBar()
        menuBar.Append(menu, "File") 
        parent.SetMenuBar(menuBar)  
        button = wx.Button(self, label="Print", pos=(0,60))
        self.Bind(wx.EVT_BUTTON, self.writeToSharedQueue, button)
        self.textBox = wx.TextCtrl(self, size=(280,50), style=wx.TE_MULTILINE)   

    #-----------------------------------------------------------------
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def writeToSharedQueue(self, event):
        self.textBox.AppendText(
                        "The Print Button has been clicked!\n") 
        putDataIntoQueue('Hi from wxPython via Shared Queue.\n')
        if dataInQueue: 
            data = readDataFromQueue()
            self.textBox.AppendText(data)

            text.insert('0.0', data) # insert data into tkinter GUI

#==================================================================
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def useQueues(self):
        # Now using a class member Queue        
        while True: 
            qItem = self.guiQueue.get()
            print(qItem)
            self.scr.insert(tk.INSERT, qItem + '\n') 

    # Button callback
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def insertQuote(self):
        title = self.bookTitle.get()
        page = self.pageNumber.get()
        quote = self.quote.get(1.0, tk.END)
        print(title)
        print(quote)
        self.mySQL.insertBooks(title, page, quote)     

    # Button callback
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def modifyQuote(self):
        raise NotImplementedError("This still needs to be implemented for the SQL command.")

    # TZ Button callback
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def allTimeZones(self):
        for tz in all_timezones:
            self.scr.insert(tk.INSERT, tz + '\n')

    # TZ Local Button callback
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def __init__(self): 
        # Create instance
        self.win = tk.Tk()   

        # Add a title       
        self.win.title("Python GUI")      
        self.createWidgets()

    # Button callback
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def clickMe(self):
        self.action.configure(text='Hello ' + self.name.get())

    # Button callback Clear Text
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def clickMe(self):
        self.action.configure(text='Hello ' + self.name.get())

    # Button callback Clear Text
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def clickMe(button, name, number):
    button.configure(text='Hello {} {}'.format(name.get(), number.get()))

# Button callback Clear Text
项目:Python-GUI-Programming-Cookbook-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def display_button(active_notebook, tab_no):
    btn = ttk.Button(display_area, text=active_notebook +' - Tab '+ tab_no, \
                     command= lambda: showinfo("Tab Display", "Tab: " + tab_no) )
    btn.grid(column=0, row=0, padx=8, pady=8)     

#------------------------------------------