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

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

项目: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)
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def chosen(self, label, items, choice, name):
        #for child in self.mainframe.winfo_children():
        #   child.destroy()
        self.add_emoji()
        self.add_trace()
        self.set_title(label)

        ind = 0
        for item in items:
            col = ind%4 + 1
            row = ind/4 + 1
            if name=="true":
                if item==choice:
                    ttk.Button(self.mainframe, text=item).grid(column=col, row=row, sticky=N+S+E+W)
                else:
                    ttk.Button(self.mainframe, text="").grid(column=col, row=row, sticky=N+S+E+W)
            else:
                if item==choice:
                    ttk.Button(self.mainframe, text=item, image=images[item], compound="top").grid(column=col, row=row, sticky=N+S+E+W)
                else:
                    ttk.Button(self.mainframe, text="", image=gray, compound="top").grid(column=col, row=row, sticky=N+S+E+W)
            ind+=1
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def robot(self, label,items, name):
        for child in self.mainframe.winfo_children():
            child.destroy()
        self.add_emoji()
        self.add_trace()
        self.set_title(label)

        ind = 0
        for item in items:
            col = ind%4 + 1
            row = ind/4 + 1
            if name=="true":
                ttk.Button(self.mainframe, text=item).grid(column=col, row=row, sticky=N+S+E+W)
            else:
                ttk.Button(self.mainframe, text=item, image=images[item], compound="top").grid(column=col, row=row, sticky=N+S+E+W)
            ind+=1
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def chosen(self, label, items, choice, name):
        #for child in self.mainframe.winfo_children():
        #   child.destroy()
        self.add_emoji()
        self.add_trace()
        self.set_title(label)

        ind = 0
        for item in items:
            col = ind%4 + 1
            row = ind/4 + 1
            if name=="true":
                if item==choice:
                    ttk.Button(self.mainframe, text=item).grid(column=col, row=row, sticky=N+S+E+W)
                else:
                    ttk.Button(self.mainframe, text="").grid(column=col, row=row, sticky=N+S+E+W)
            else:
                if item==choice:
                    ttk.Button(self.mainframe, text=item, image=images[item], compound="top").grid(column=col, row=row, sticky=N+S+E+W)
                else:
                    ttk.Button(self.mainframe, text="", image=gray, compound="top").grid(column=col, row=row, sticky=N+S+E+W)
            ind+=1
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def robot(self, label,items, name):
        for child in self.mainframe.winfo_children():
            child.destroy()
        self.add_emoji()
        self.add_trace()
        self.set_title(label)

        ind = 0
        for item in items:
            col = ind%4 + 1
            row = ind/4 + 1
            if name=="true":
                ttk.Button(self.mainframe, text=item).grid(column=col, row=row, sticky=N+S+E+W)
            else:
                ttk.Button(self.mainframe, text=item, image=images[item], compound="top").grid(column=col, row=row, sticky=N+S+E+W)
            ind+=1
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def chosen(self, label, items, choice, name):
        #for child in self.mainframe.winfo_children():
        #   child.destroy()
        self.add_emoji()
        self.add_trace()
        self.set_title(label)

        ind = 0
        for item in items:
            col = ind%4 + 1
            row = ind/4 + 1
            if name=="true":
                if item==choice:
                    ttk.Button(self.mainframe, text=item).grid(column=col, row=row, sticky=N+S+E+W)
                else:
                    ttk.Button(self.mainframe, text="").grid(column=col, row=row, sticky=N+S+E+W)
            else:
                if item==choice:
                    ttk.Button(self.mainframe, text=item, image=images[item], compound="top").grid(column=col, row=row, sticky=N+S+E+W)
                else:
                    ttk.Button(self.mainframe, text="", image=gray, compound="top").grid(column=col, row=row, sticky=N+S+E+W)
            ind+=1
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def _setup_widgets(self):
        themes_lbl = ttk.Label(self, text="Themes")

        themes = self.style.theme_names()
        self.themes_combo = ttk.Combobox(self, values=themes, state="readonly")
        self.themes_combo.set(themes[0])
        self.themes_combo.bind("<<ComboboxSelected>>", self._theme_sel_changed)

        change_btn = ttk.Button(self, text='Change Theme',
            command=self._change_theme)

        theme_change_checkbtn = ttk.Checkbutton(self,
            text="Change themes when combobox item is activated",
            variable=self.theme_autochange)

        themes_lbl.grid(ipadx=6, sticky="w")
        self.themes_combo.grid(row=0, column=1, padx=6, sticky="ew")
        change_btn.grid(row=0, column=2, padx=6, sticky="e")
        theme_change_checkbtn.grid(row=1, columnspan=3, sticky="w", pady=6)

        top = self.winfo_toplevel()
        top.rowconfigure(0, weight=1)
        top.columnconfigure(0, weight=1)
        self.columnconfigure(1, weight=1)
        self.grid(row=0, column=0, sticky="nsew", columnspan=3, rowspan=2)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def _new_state(self, widget, newtext):
        widget = self.nametowidget(widget)

        if not newtext:
            goodstates = ["disabled"]
            font_extra = 0
        else:
            # set widget state according to what has been entered in the entry
            newstates = set(newtext.split()) # eliminate duplicates

            # keep only the valid states
            goodstates = [state for state in newstates if state in states]
            # define a new font size based on amount of states
            font_extra = 2 * len(goodstates)

        # set new widget state
        for widget in self.update_widgets:
            reset_state(widget) # remove any previous state from the widget
            widget.state(goodstates)

        # update Ttk Button font size
        self._set_font(font_extra)
        return 1
项目:audiojack-ui    作者:anilee    | 项目源码 | 文件源码
def search(self, event=None):
        global run
        run = True
        input = self.url_input.get(0.0, END).replace('\n', '').replace(' ', '').replace('\t', '')
        self.reset()
        self.q = Queue.Queue()
        t = Thread(target=self.get_results, args=[input])
        t.daemon = True
        t.start()
        self.disable_search()
        self.search_progress = ttk.Progressbar(self.mainframe, length=200, mode='indeterminate')
        self.search_progress.pack()
        self.search_progress.start(20)
        self.cancel = ttk.Button(self.mainframe, text='Cancel', command=self.cancel_search)
        self.cancel.pack()
        self.master.after(100, self.add_results)
项目:audiojack-ui    作者:anilee    | 项目源码 | 文件源码
def create_custom_frame(self):
        self.custom_frame = ttk.Frame(self.mainframe)
        self.custom_title = ttk.Label(self.custom_frame, text='Custom tags:')
        self.artist_label = ttk.Label(self.custom_frame, text='Artist: ')
        self.artist_input = Text(self.custom_frame, width=20, height=1, font=self.font)
        self.title_label = ttk.Label(self.custom_frame, text='Title: ')
        self.title_input = Text(self.custom_frame, width=20, height=1, font=self.font)
        self.album_label = ttk.Label(self.custom_frame, text='Album: ')
        self.album_input = Text(self.custom_frame, width=20, height=1, font=self.font)
        self.cover_art = ttk.Button(self.custom_frame, text='Browse for cover art', command=self.cover_art_browse)
        self.cover_art_path = Entry(self.custom_frame, width=20, font=self.font)
        self.custom_submit = ttk.Button(self.custom_frame, text='Download using custom tags', command=self.custom)
        self.custom_title.grid(row=0, columnspan=2)
        self.artist_label.grid(column=0, row=1)
        self.artist_input.grid(column=1, row=1)
        self.title_label.grid(column=0, row=2)
        self.title_input.grid(column=1, row=2)
        self.album_label.grid(column=0, row=3)
        self.album_input.grid(column=1, row=3)
        self.cover_art.grid(column=0, row=4)
        self.cover_art_path.grid(column=1, row=4)
        self.custom_submit.grid(row=5, columnspan=2, sticky=EW, pady=10)
        self.custom_frame.pack(pady=10)
项目:audiojack-ui    作者:anilee    | 项目源码 | 文件源码
def add_file(self):
        try:
            result = self.download_queue.get(0)
            if result == 0:
                self.error = ttk.Label(self.mainframe, text='Error: ffmpeg is not installed.', font=self.font, foreground='#ff0000')
                self.error.pack()
            else:
                self.file = result.replace('/', '\\')
                text = 'Open %s' % self.file
                self.file_button = ttk.Button(self.mainframe, text=text, command=partial(self.open_file, self.file))
                self.file_button.pack()
            self.enable_search()
            self.download_progress.pack_forget()
            self.download_progress.destroy()
            self.results_label.pack_forget()
            self.results_label.destroy()
            self.results_frame.pack_forget()
            self.results_frame.destroy()
        except Queue.Empty:
            self.master.after(100, self.add_file)
项目:PIEFACE    作者:jcumby    | 项目源码 | 文件源码
def raise_message(log):
    if "Label(s) %s are not present" in log.msg:
        box = tk.Toplevel(root)
        box.title('Error')
        message = ttk.Label(box, text = log.msg % log.args)
        labels = {}
        for f in app.filenames:
            labels[os.path.basename(f)] = " ".join(sorted(multiCIF._alllabels(f)))
        advice = ttk.Label(box, text = "Valid labels are:\n{0}".format( "".join( ["{0:40s}: {1:30s}\n".format(p, labels[p]) for p in labels] )))
        tip = ttk.Label(box, text="[ Tip: Regular expressions can also be used to centre labels ]")
        button = ttk.Button(box, text='OK', command= lambda: box.destroy())
        message.grid(row = 0, padx = 5, pady = 5)
        advice.grid(row = 1, padx = 5, pady = 5)
        tip.grid(row=2, padx=5, pady=5)
        button.grid(row = 3, padx = 5, pady = 5)
        root.wait_window(window=box)
    else:
        pass

    #tkMessageBox.showerror('Error',log.msg)
项目:heartbreaker    作者:lokori    | 项目源码 | 文件源码
def __init__(self, parent, buttontext, mycommand,r,c):
        ttk.Button.__init__(self, parent)
        self.config(text = buttontext, command=mycommand)
        self.grid(row=r,column=c)
项目:StochOPy    作者:keurfonluu    | 项目源码 | 文件源码
def footer(self):
        # Run button
        run_button = ttk.Button(self.master, text = "Run", command = self.run)

        # Exit button
        exit_button = ttk.Button(self.master, text = "Exit", command = self.close_window)

        # Layout
        run_button.place(relwidth = 0.1, relx = 0.9, rely = 1, x = -5, y = -5, anchor = "se")
        exit_button.place(relwidth = 0.1, relx = 1, rely = 1, x = -5, y = -5, anchor = "se")
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def __init__(self,choice,frame,row,col):
        self.choice = choice
        self.button = ttk.Button(frame, text=self.choice, image=images[self.choice], compound="top",command=lambda:human_choice(self.choice)).grid(column=col, row=row, sticky=N+S+E+W)
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def __init__(self,choice,frame,row,col):
        self.choice = choice
        self.button = ttk.Button(frame, text=self.choice,command=lambda:human_choice(self.choice)).grid(column=col, row=row, sticky=N+S+E+W)
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def __init__(self,choice,frame,row,col):
        self.choice = choice
        self.button = ttk.Button(frame, text=self.choice, image=images[self.choice], compound="top",command=lambda:human_prediction(self.choice)).grid(column=col, row=row, sticky=N+S+E+W)
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def __init__(self,choice,frame,row,col):
        self.choice = choice
        self.button = ttk.Button(frame, text=self.choice,command=lambda:human_prediction(self.choice)).grid(column=col, row=row, sticky=N+S+E+W)

################################################
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def add_emoji(self):
        ttk.Button(self.mainframe, text="good", image=good, compound="top", command=lambda:juge("good")).grid(column=1, row=4, sticky=N+S+E+W)
        ttk.Button(self.mainframe, text="lol", image=lol, compound="top", command=lambda:juge("lol")).grid(column=2, row=4, sticky=N+S+E+W)
        ttk.Button(self.mainframe, text="wtf", image=wtf, compound="top", command=lambda:juge("wtf")).grid(column=3, row=4, sticky=N+S+E+W)
        ttk.Button(self.mainframe, text="bad", image=bad, compound="top", command=lambda:juge("bad")).grid(column=4, row=4, sticky=N+S+E+W)
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def __init__(self,choice,frame,row,col):
        self.choice = choice
        self.button = ttk.Button(frame, text=self.choice, image=images[self.choice], compound="top",command=lambda:human_choice(self.choice)).grid(column=col, row=row, sticky=N+S+E+W)
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def __init__(self,choice,frame,row,col):
        self.choice = choice
        self.button = ttk.Button(frame, text=self.choice,command=lambda:human_choice(self.choice)).grid(column=col, row=row, sticky=N+S+E+W)
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def __init__(self,choice,frame,row,col):
        self.choice = choice
        self.button = ttk.Button(frame, text=self.choice, image=images[self.choice], compound="top",command=lambda:human_prediction(self.choice)).grid(column=col, row=row, sticky=N+S+E+W)
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def __init__(self,choice,frame,row,col):
        self.choice = choice
        self.button = ttk.Button(frame, text=self.choice,command=lambda:human_prediction(self.choice)).grid(column=col, row=row, sticky=N+S+E+W)

################################################
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def __init__(self,choice,frame,row,col):
        self.choice = choice
        self.button = ttk.Button(frame, text=self.choice, image=images[self.choice], compound="top",command=lambda:human_choice(self.choice)).grid(column=col, row=row, sticky=N+S+E+W)
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def __init__(self,choice,frame,row,col):
        self.choice = choice
        self.button = ttk.Button(frame, text=self.choice,command=lambda:human_choice(self.choice)).grid(column=col, row=row, sticky=N+S+E+W)
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def __init__(self,choice,frame,row,col):
        self.choice = choice
        self.button = ttk.Button(frame, text=self.choice, image=images[self.choice], compound="top",command=lambda:human_prediction(self.choice)).grid(column=col, row=row, sticky=N+S+E+W)
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def add_emoji(self):
        ttk.Button(self.mainframe, text="good", image=good, compound="top", command=lambda:juge("good")).grid(column=1, row=4, sticky=N+S+E+W)
        ttk.Button(self.mainframe, text="lol", image=lol, compound="top", command=lambda:juge("lol")).grid(column=2, row=4, sticky=N+S+E+W)
        ttk.Button(self.mainframe, text="absurd", image=wtf, compound="top", command=lambda:juge("wtf")).grid(column=3, row=4, sticky=N+S+E+W)
        ttk.Button(self.mainframe, text="bad", image=bad, compound="top", command=lambda:juge("bad")).grid(column=4, row=4, sticky=N+S+E+W)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def setUp(self):
        super(WidgetTest, self).setUp()
        self.widget = ttk.Button(self.root, width=0, text="Text")
        self.widget.pack()
        self.widget.wait_visibility()
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Button(self.root, **kwargs)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_invoke(self):
        success = []
        btn = ttk.Button(self.root, command=lambda: success.append(1))
        btn.invoke()
        self.assertTrue(success)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def __setup_styles(self):
        # custom ttk styles
        style = ttk.Style(self.master)
        arrow_layout = lambda dir: (
            [('Button.focus', {'children': [('Button.%sarrow' % dir, None)]})]
        )
        style.layout('L.TButton', arrow_layout('left'))
        style.layout('R.TButton', arrow_layout('right'))
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def __place_widgets(self):
        # header frame and its widgets
        hframe = ttk.Frame(self)
        lbtn = ttk.Button(hframe, style='L.TButton', command=self._prev_month)
        rbtn = ttk.Button(hframe, style='R.TButton', command=self._next_month)
        self._header = ttk.Label(hframe, width=15, anchor='center')
        # the calendar
        self._calendar = ttk.Treeview(show='', selectmode='none', height=7)

        # pack the widgets
        hframe.pack(in_=self, side='top', pady=4, anchor='center')
        lbtn.grid(in_=hframe)
        self._header.grid(in_=hframe, column=1, row=0, padx=12)
        rbtn.grid(in_=hframe, column=2, row=0)
        self._calendar.pack(in_=self, expand=1, fill='both', side='bottom')
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def _setup_widgets(self):
        btn = ttk.Button(self, text='Enter states and watch')

        entry = ttk.Entry(self, cursor='xterm', validate="key")
        entry['validatecommand'] = (self.register(self._new_state), '%W', '%P')
        entry.focus()

        self.update_widgets.append(btn)
        entry.validate()

        entry.pack(fill='x', padx=6)
        btn.pack(side='left', pady=6, padx=6, anchor='n')
        self.pack(fill='both', expand=1)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Button(self.root, **kwargs)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_invoke(self):
        success = []
        btn = ttk.Button(self.root, command=lambda: success.append(1))
        btn.invoke()
        self.assertTrue(success)
项目:aurora-sdk-win    作者:nanoleaf    | 项目源码 | 文件源码
def show_window(self):
        self.mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
        self.mainframe.columnconfigure(0, weight=1)
        self.mainframe.rowconfigure(0, weight=1)

        ttk.Label(self.mainframe, text="             ").grid(column=0, row=0, sticky=(N,W))
        ttk.Label(self.mainframe, text='1. Pair your Aurora').grid(column=1, row=1, sticky=(N, W))

        ttk.Label(self.mainframe, text='IP Address').grid(column=1, row=2, sticky=(N, W))
        ttk.Entry(self.mainframe, width=35, textvariable=self.ip_addr).grid(column=2, row=2, columnspan=2, sticky=(N, W))
        ttk.Button(self.mainframe, width=12, text='Pair', command=self.authenticate_with_aurora).grid(column=4, row=2, sticky=(N,W))

        ttk.Label(self.mainframe, text='2. Make a color palette').grid(column=1, row=3, sticky=(N, W))

        ttk.Button(self.mainframe, text="Add Color", command=self.add_color_to_palette).grid(column=1, row=4, sticky=(N, W))
        ttk.Label(self.mainframe, textvariable=self.curr_palette_string, wraplength=500).grid(column=2, row=4, columnspan=2, sticky=(N, W))
        ttk.Button(self.mainframe, width=12, text="Clear palette", command=self.clear_palette).grid(column=4, row=4, sticky=(N, W))

        if (not self.is_windows):
            ttk.Label(self.mainframe, text='3. Build your plugin').grid(column=1, row=5, sticky=(N, W))
        else:
            ttk.Button(self.mainframe, width=18, text="Generate Palette", command=self.write_palette_for_sdk).grid(column=1, row=5, sticky=(N, W))

        ttk.Label(self.mainframe, text='Plugin Location').grid(column=1, row=6, sticky=(N, W))
        ttk.Entry(self.mainframe, width=35, textvariable=self.plugin_dir_path).grid(column=2, row=6, columnspan=2, sticky=(N, W))
        ttk.Button(self.mainframe, width=12, text='Browse', command=self.get_plugin_dir).grid(column=4, row=6, sticky=(N, W))

        if (not self.is_windows):
            ttk.Button(self.mainframe, text='Build', command=self.build_plugin).grid(column=2, row=7, columnspan=1, sticky=(N,E))
            ttk.Button(self.mainframe, text='Upload & Run', command=self.play_plugin).grid(column=3, row=7, columnspan=1, sticky=N)
            ttk.Button(self.mainframe, width=12, text='Stop Plugin', command=self.stop_plugin).grid(column=4, row=7, columnspan=1, sticky=(N, W))

        ttk.Label(self.mainframe, text="             ").grid(column=5, row=8, sticky=(N,W))
        ttk.Label(self.mainframe, text="             ").grid(column=5, row=9, sticky=(N,W))

        self.root.mainloop()
项目:PyLanMessenger    作者:stoic1979    | 项目源码 | 文件源码
def show_popup(self):
        popup = Tk()
        popup.wm_title("Msg from %s" % host)
        popup.geometry("480x320+300+300")
        label = Label(popup, text=msg)
        label.pack(side="top", fill="x", pady=10)
        B1 = Button(popup, text="Okay", command = popup.destroy)
        B1.pack()
        popup.mainloop()
项目:Archie    作者:niccroad    | 项目源码 | 文件源码
def _addModules(self, frame, matrix_labels, ui, layer, horizontal, item, modules):
        for module in modules:
            if isinstance(module, ModuleCollection):
                if module.is_loop:
                    item = self._addModules(frame,
                                            matrix_labels,
                                            ui,
                                            layer,
                                            horizontal,
                                            item,
                                            module.module_list)
                    continue

                sub_state = HeaderState(module.module_list,
                                        frame,
                                        matrix_labels,
                                        ui,
                                        layer + 1,
                                        horizontal)
                self.sub_header_states.append(sub_state)

            if horizontal:
                button = ttk.Button(frame,
                                    text=str(module),
                                    command=lambda col=item: self._toggleCol(col))
            else:
                button = ttk.Button(frame,
                                    text=str(module),
                                    command=lambda row=item: self._toggleRow(row))
            self.buttons.append(button)
            item = item + 1
        return item
项目:audio-tagging-toolkit    作者:hipstas    | 项目源码 | 文件源码
def write_music():
    fo.write('''"'''+current_file+'''"'''+', music\n')
    time.sleep(0.1)
    mixer.stop()
    mixer.init()
    play_sound()





#btn = ttk.Button(c, text="load image", command=showImage)
#lbl1 = ttk.Label(c)
#btn.grid(column=0, row=0, sticky=N, pady=5, padx=5)
#lbl1.grid(column=1, row=1, sticky=N, pady=5, padx=5)
项目:bemoss_gui2.1    作者:bemoss    | 项目源码 | 文件源码
def __init__(self):

        self.passwd = None
        self.do_update = False

        # current working directory
        self.cwd = os.getcwd()
        self.bemoss_dir = self.cwd.replace('bemoss_gui', 'bemoss_os/')

        img_path = self.find_img()
        self.logo = ImageTk.PhotoImage(Image.open(img_path).resize((350,125)))
        self.img = ttk.Label(root, image=self.logo, justify='center')
        self.img.pack(fill=Tkinter.Y, expand=True, padx=5, pady=30)
        # logoimage

        self.ip_addr = self.getIPs()
        self.ipframe = Tkinter.LabelFrame(root, text='Your IP address:')
        self.ip_label = Tkinter.Label(self.ipframe, text=self.ip_addr, font=('Courier', 12, 'bold'))
        self.ip_label.pack()
        self.ipframe.pack(fill=Tkinter.X, expand=True, padx=15)
        # IP

        self.button_quit = ttk.Button(root, text='Run BEMOSS', command=self.run_software)
        self.button_quit.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=True, pady=15, padx=10)
        self.button_runNode = ttk.Button(root, text='Run BEMOSS Node', command=self.run_software_asnode)
        self.button_runNode.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=True, pady=15, padx=10)
        self.button_run = ttk.Button(root, text='Stop BEMOSS', command=self.stop_software)
        self.button_run.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=True, pady=15, padx=10)
        self.button_adv = ttk.Button(root, text='Advanced Setting', command=self.adv_set)
        self.button_adv.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=True, pady=15, padx=10)


        # buttons
项目:bemoss_gui2.1    作者:bemoss    | 项目源码 | 文件源码
def get_passwd(self):
        self.passwd_window = Tkinter.Toplevel(self.frame2)
        self.passwd_window.title('Log In')
        x = self.frame2.winfo_rootx()
        y = self.frame2.winfo_rooty()
        self.passwd_window.geometry('350x130+%d+%d' % (x+150, y+100))
        self.passwd_window.lift()
        self.passwd_window.columnconfigure(0, weight=1)
        self.passwd_window.columnconfigure(1, weight=1)
        self.passwd_window.columnconfigure(2, weight=1)
        self.passwd_window.columnconfigure(3, weight=2)
        self.passwd_window.columnconfigure(4, weight=2)
        self.passwd_window.columnconfigure(5, weight=1)
        self.passwd_window.rowconfigure(0, weight=1)
        self.passwd_window.rowconfigure(1, weight=2)
        self.passwd_window.rowconfigure(2, weight=2)
        self.passwd_window.rowconfigure(3, weight=2)
        self.passwd_window.rowconfigure(4, weight=1)
        self.passwd_window.resizable(False, False)
        reminder = ttk.Label(self.passwd_window, text='Please input the system password.')
        reminder.grid(row=1, column=1, columnspan=4, sticky='w')
        self.pswd = Tkinter.StringVar()
        pwentry = Tkinter.Entry(self.passwd_window, textvariable=self.pswd, width=30)
        pwentry.focus_set()
        pwentry.grid(row=2, column=3, columnspan=2, sticky='w', padx=10)
        pwentry.config(show='*')
        pswdlabel = ttk.Label(self.passwd_window, text='Password:')
        pswdlabel.grid(row=2, column=2, sticky='e', padx=10)
        confirm_but = ttk.Button(self.passwd_window, text='Confirm', command=self.pwconfirm)
        confirm_but.grid(row=3, column=4, sticky='w', padx=5)
        clear_but = ttk.Button(self.passwd_window, text='Clear',
                               command=lambda: pwentry.delete(0, Tkinter.END))
        clear_but.grid(row=3, column=3, sticky='e', padx=5)
        self.passwd_window.bind('<Return>', self.shortcut)
项目:bemoss_gui2.1    作者:bemoss    | 项目源码 | 文件源码
def get_passwd_ocf(self):
        self.passwd_window_ocf = Tkinter.Toplevel(self.frame3)
        self.passwd_window_ocf.title('Postgres Auth(System Password)')
        x = self.frame3.winfo_rootx()
        y = self.frame3.winfo_rooty()
        self.passwd_window_ocf.geometry('350x130+%d+%d' % (x+150, y+100))
        self.passwd_window_ocf.lift()
        self.passwd_window_ocf.columnconfigure(0, weight=1)
        self.passwd_window_ocf.columnconfigure(1, weight=1)
        self.passwd_window_ocf.columnconfigure(2, weight=1)
        self.passwd_window_ocf.columnconfigure(3, weight=2)
        self.passwd_window_ocf.columnconfigure(4, weight=2)
        self.passwd_window_ocf.columnconfigure(5, weight=1)
        self.passwd_window_ocf.rowconfigure(0, weight=1)
        self.passwd_window_ocf.rowconfigure(1, weight=2)
        self.passwd_window_ocf.rowconfigure(2, weight=2)
        self.passwd_window_ocf.rowconfigure(3, weight=2)
        self.passwd_window_ocf.rowconfigure(4, weight=1)
        self.passwd_window_ocf.resizable(False, False)
        reminder = ttk.Label(self.passwd_window_ocf, text='Please input the system password.')
        reminder.grid(row=1, column=1, columnspan=4, sticky='w')
        self.pswd_ocf = Tkinter.StringVar()
        pwentry = Tkinter.Entry(self.passwd_window_ocf, textvariable=self.pswd_ocf, width=30)
        pwentry.focus_set()
        pwentry.grid(row=2, column=3, columnspan=2, sticky='w', padx=10)
        pwentry.config(show='*')
        pswdlabel = ttk.Label(self.passwd_window_ocf, text='Password:')
        pswdlabel.grid(row=2, column=2, sticky='e', padx=10)
        confirm_but = ttk.Button(self.passwd_window_ocf, text='Confirm', command=self.pwconfirm_ocf)
        confirm_but.grid(row=3, column=4, sticky='w', padx=5)
        clear_but = ttk.Button(self.passwd_window_ocf, text='Clear',
                               command=lambda: pwentry.delete(0, Tkinter.END))
        clear_but.grid(row=3, column=3, sticky='e', padx=5)
        self.passwd_window_ocf.bind('<Return>', self.shortcut3)
项目:bemoss_gui2.1    作者:bemoss    | 项目源码 | 文件源码
def start_cas(self):
        # add log in pop up here to let the user to input the username and password. Save then in cas_usr and cas_pw
        self.login_window = Tkinter.Toplevel(root)
        self.login_window.title('Cassandra Log in')
        self.login_window.lift()
        x = self.frame3.winfo_rootx()
        y = self.frame3.winfo_rooty()
        self.login_window.geometry('300x170+%d+%d' % (x+150, y+100))
        self.login_window.rowconfigure(0, weight=1)
        self.login_window.rowconfigure(1, weight=1)
        self.login_window.rowconfigure(2, weight=1)
        self.login_window.rowconfigure(3, weight=1)
        self.login_window.rowconfigure(4, weight=1)
        self.login_window.columnconfigure(0, weight=1)
        self.login_window.columnconfigure(1, weight=1)
        self.login_window.columnconfigure(2, weight=1)
        self.login_window.columnconfigure(3, weight=1)
        self.login_window.resizable(False, False)
        unlabel = ttk.Label(self.login_window, text='Username:')
        unlabel.grid(row=1, column=1)
        pwlabel = ttk.Label(self.login_window, text='Password:')
        pwlabel.grid(row=2, column=1)
        self.username_cas = Tkinter.StringVar()
        self.password_cas = Tkinter.StringVar()
        unentry = ttk.Entry(self.login_window, textvariable=self.username_cas, width=20)
        unentry.focus_set()
        unentry.grid(row=1, column=2)
        pwentry = ttk.Entry(self.login_window, textvariable=self.password_cas, width=20)
        pwentry.grid(row=2, column=2)
        pwentry.configure(show='*')
        conf_but = ttk.Button(self.login_window, text='Confirm', command=self.checkuser)
        conf_but.grid(row=3, column=2, sticky='e')
        self.login_window.bind('<Return>', self.shortcut2)
项目:audiojack-ui    作者:anilee    | 项目源码 | 文件源码
def add_results(self):
        try:
            self.results_images = self.q.get(0)
            self.search_progress.pack_forget()
            self.search_progress.destroy()
            self.cancel.pack_forget()
            self.cancel.destroy()
            if self.results_images == 0:
                self.reset()
            elif self.results_images == -1:    # If the URL is invalid
                self.error = ttk.Label(self.mainframe, text='Error: Invalid URL', font=self.font, foreground='#ff0000')
                self.error.pack()       # Create an error message
                self.enable_search()    # Enable the search option again
            elif self.results_images == -2:
                self.error = ttk.Label(self.mainframe, text='Error: Network error', font=self.font, foreground='#ff0000')
                self.error.pack()       # Create an error message
                self.enable_search()    # Enable the search option again
            else:
                self.enable_search()
                self.results = self.results_images[0]
                self.images = self.results_images[1]
                self.results_frame = ttk.Frame(self.mainframe)
                self.results_label = ttk.Label(self.mainframe, text='Results:', font=self.font)
                self.results_label.pack()
                for i, result in enumerate(self.results):
                    text = '%s\n%s\n%s' % (result[0], result[1], result[2])
                    self.result = ttk.Button(self.results_frame, text=text, image=self.images[i], compound=TOP, command=partial(self.download, i))
                    self.result.grid(column=i%4, row=i/4)
                self.results_frame.pack()
                self.create_custom_frame()
        except Queue.Empty:
            self.master.after(100, self.add_results)
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def setUp(self):
        support.root_deiconify()
        self.widget = ttk.Button(width=0, text="Text")
        self.widget.pack()
        self.widget.wait_visibility()
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def test_invoke(self):
        success = []
        btn = ttk.Button(command=lambda: success.append(1))
        btn.invoke()
        self.assertTrue(success)
项目:Python-Media-Player    作者:surajsinghbisht054    | 项目源码 | 文件源码
def create_control_panel(self):
        frame=Tkinter.LabelFrame(self.root)
        frame.pack(expand='yes',fill='x',side='top')
        add_fileicon=Tkinter.PhotoImage(file="../Icons/add_file.gif")
        add_directoryicon=Tkinter.PhotoImage(file="../Icons/add_directory.gif")
        exiticon=Tkinter.PhotoImage(file="../Icons/exit.gif")
        playicon=Tkinter.PhotoImage(file="../Icons/play.gif")
        pauseicon=Tkinter.PhotoImage(file="../Icons/pause.gif")
        stopicon=Tkinter.PhotoImage(file="../Icons/stop.gif")
        rewindicon=Tkinter.PhotoImage(file="../Icons/rewind.gif")
        fast_forwardicon=Tkinter.PhotoImage(file="../Icons/fast_forward.gif")
        previous_trackicon=Tkinter.PhotoImage(file="../Icons/previous_track.gif")
        next_trackicon=Tkinter.PhotoImage(file="../Icons/next_track.gif")
        self.muteicon=Tkinter.PhotoImage(file="../Icons/mute.gif")
        self.unmuteicon=Tkinter.PhotoImage(file="../Icons/unmute.gif")
        delete_selectedicon=Tkinter.PhotoImage(file="../Icons/delete_selected.gif")

        list_file=[
            (playicon,'self.play'),
            (pauseicon,'self.pause'),
            (stopicon,'self.stop'),
            (previous_trackicon,'self.previous'),
            (rewindicon,'self.rewind'),
            (fast_forwardicon,'self.fast'),
            (next_trackicon,'self.Next'),]
        for i,j in list_file:
            storeobj=ttk.Button(frame, image=i,command=eval(j))
            storeobj.pack(side='left')
            storeobj.image=i
        self.volume_label=Tkinter.Button(frame,image=self.unmuteicon)
        self.volume_label.image=self.unmuteicon

        volume=ttk.Scale(frame,from_=Volume_lowest_value, to=Volume_highest_value ,variable=self.var, command=self.update_volume)
        volume.pack(side='right', padx=10, )
        self.volume_label.pack(side='right')
        return
项目:download-npo    作者:Carpetsmoker    | 项目源码 | 文件源码
def make_progress_frame_entry(self, label_text, video):
        # +-------------------------------------------------+
        # | *Titel*                   start/pause] [cancel] |
        # | progress                                        |
        # +-------------------------------------------------+
        video['progress'] = tk.StringVar()
        video['progress'].set('Nog niet gestart')

        frame = ttk.Frame(self.progress_frame, relief=tk.GROOVE, borderwidth=10)
        video['frame'] = frame
        print(video['row'])
        frame.grid(row=video['row'], sticky=tk.W + tk.E + tk.N, column=0)
        # paned.grid(row=0, column=0, sticky=tk.E + tk.W + tk.N + tk.S)

        title = tk.Label(frame, text=label_text)
        title.grid(row=0, column=0, sticky=tk.W)

        video['start_pause'] = tk.StringVar()
        video['start_pause'].set('Start')
        btn = ttk.Button(frame, textvariable=video['start_pause'], style='Small.TButton',
                         command=lambda: self.start_or_pause_video(video))
        btn.grid(row=0, column=1, sticky=tk.E)

        cancel = ttk.Button(frame, text='Annuleren', style='Small.TButton',
                            command=lambda: self.cancel_video(video))
        cancel.grid(row=0, column=2, sticky=tk.E)

        progress = tk.Label(frame, textvariable=video['progress'])
        progress.grid(row=1, column=0, sticky=tk.W)
项目:PIEFACE    作者:jcumby    | 项目源码 | 文件源码
def __init__(self, parent=None):
        self.parent = parent
        tk.Toplevel.__init__(self)
        #self.win = tk.Toplevel(parent)
        self.iconbitmap(iconloc)
        self.title('Busy')
        self.resizable(False, False)
        self.message = ttk.Label(self, text='Please wait. This may take a long time.')
        self.message.grid(column = 0, row=0, sticky = tk.N, padx=5, pady=5)
        self.prog = ttk.Progressbar(self, mode = 'indeterminate', orient=tk.HORIZONTAL, maximum=30)
        self.prog.grid(column=0, row=1, sticky=(tk.E, tk.W), padx=5, pady=5)
        tip = ttk.Label(self, text='[Tip: Perhaps a good time for a coffee?]')
        tip.grid(column=0, row=2, sticky=tk.S, padx=5, pady=5)
        #self.cancel = ttk.Button(self, text='Cancel', command=self.cancel)
        #self.cancel.grid(column=0, row=2, pady=5)