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

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

项目:Smart-Trader    作者:i-sultan    | 项目源码 | 文件源码
def __init__(self):
        tk.Tk.__init__(self)
        tk.Tk.wm_title(self, "Smart Trader System")
        if os.name == "nt":
            tk.Tk.iconbitmap(self, default="app_icon.ico")
        self.configure(background = StColors.dark_grey)
        set_app_style()

        # Top section (header)
        title = ttk.Label(self, text="Smart Trader Portal", font=("Tahoma", 25, 'bold'))
        title.pack()

        # Lower section (tabs area)
        notebook = ttk.Notebook(self)
        notebook.pack()
        # Create Controllers and add their views
        explore = ExploreController(self)
        train   = TrainingController(self)
        backtest= BacktestController(self)
        forecast= ForecastController(self)
        for view_frame in (explore.view, train.view, backtest.view, forecast.view):
            view_frame.grid(row=0, column=0, sticky="nsew")
            notebook.add(view_frame, text = view_frame.title)
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __init__(self, panedwindow, sash_index, disallow_dragging=False, on_click=None, **kw):
        image = kw.pop("image", None)
        Frame.__init__(self, panedwindow, class_="Handle", **kw)

        self._sash_index = sash_index

        if image:
            self._event_area = Label(self, image=image)
            self._event_area.pack()            
        else:
            self._event_area = self

        self._center = int(self._event_area.winfo_reqwidth()/2), int(self._event_area.winfo_reqheight()/2)

        if disallow_dragging:
            if on_click:
                self._event_area.bind('<Button-1>', lambda event: on_click())
        else:
            self._event_area.bind('<Button-1>', self._initiate_motion)
            self._event_area.bind('<B1-Motion>', self._on_dragging)
            self._event_area.bind('<ButtonRelease-1>', self.master._on_release)
项目:metlab    作者:norling    | 项目源码 | 文件源码
def __init__(self, parent, title="", optional = False, opt_func = None, *args, **options):
        Frame.__init__(self, parent, *args, **options)

        self.expanded = IntVar()
        self.expanded.set(0)

        self.enabled = IntVar()
        self.enabled.set(1)

        self.header = ttk.Frame(self)

        if optional:
            title_line = ttk.Checkbutton(self.header, text=title, variable=self.enabled, command=opt_func)
        else:
            title_line = ttk.Label(self.header, text="      %s" % (title))

        title_line.pack(side="top", fill=X)

        self.toggle_button = ttk.Checkbutton(self.header, width=2, text='+', 
                                         command=self.toggle_expanded, variable=self.expanded, style='Toolbutton')
        self.toggle_button.pack(side="left", fill=X)
        self.header.pack(fill=X, expand=1)

        self.sub_frame = Frame(self)
项目:metlab    作者:norling    | 项目源码 | 文件源码
def __init__(self, parent, title="", *args, **options):
        Frame.__init__(self, parent, *args, **options)

        header = Frame(self, bg="white")
        Label(header, text=title, font=("Helvetica", 16)).pack(side='top', anchor='nw', pady=4)
        header.pack(side="top", anchor="nw", fill=X)

        self.info = Frame(self)
        self.info_label = StringVar()
        Label(self.info, textvar=self.info_label).pack(side="top")
        self.info.pack(side="right", anchor="nw", fill=BOTH)

        self.list = Frame(self)
        self.list.pack(side="left", anchor="nw", fill=BOTH)

        self.info_frames = {}
        self.active_item = None
        self.active_info = None
项目:metlab    作者:norling    | 项目源码 | 文件源码
def add(self, item):
        item_label = Label(self.list, text=item["name"], justify="right", cursor="dotbox")
        item_label.bind("<Button-1>", self._click)
        item_label.pack(side="top", fill=X, anchor="nw", padx=(5,15))

        info = Frame(self.info)
        Label(info, text="Executed commands:").pack(side="top", anchor="nw", padx=(0,20))
        steps = Text(info, bg="grey", fg="blue", font=("Courier", 12), height=len(item["steps"])+1)
        steps.configure(state=NORMAL)
        for step in item["steps"]:
            steps.insert(END, " $ %s %s\n" % (step.split()[0].split("/")[-1], " ".join(step.split()[1:])))
        steps.see(END)
        steps.configure(state=DISABLED)
        steps.pack(side="top", anchor="nw")

        result_frame = Frame(info)

        Label(result_frame, text="Results directory: ").pack(side="left", anchor="nw", padx=(0,20))
        Label(result_frame, text=item["path"]).pack(side="left", anchor="nw", padx=(0,20))
        Button(result_frame, text="Open", command=lambda p=item["path"]:  open_in_file_browser(p) ).pack(side="left", anchor="nw", padx=(0,20))
        result_frame.pack(side="top", anchor="nw")

        Button(info, text="Delete run", command=lambda p=item: self.remove(item_label, info, p) ).pack(side="top", anchor="nw", padx=(0,20))

        self.info_frames[str(item_label)] = info
项目:StochOPy    作者:keurfonluu    | 项目源码 | 文件源码
def de_widget(self):
        # Initialize widget
        self.init_widget()

        # strategy
        self.strategy_label = ttk.Label(self.frame1.sliders, text = "Strategy")
        self.strategy_option_menu = ttk.OptionMenu(self.frame1.sliders, self.strategy, self.strategy.get(),
                                                   *sorted(self.STRATOPT))
        self.strategy_label.place(relx = 0, x = 0, y = 5, anchor = "nw")
        self.strategy_option_menu.place(relx = 0, x = 70, y = 3, anchor = "nw")

        # CR
        self._label("Crossover probability", 2)
        self._scale(0., 1., 0.01, self.CR, 2)
        self._entry(self.CR, 2)

        # F
        self._label("Differential weight", 4)
        self._scale(0., 2., 0.01, self.F, 4)
        self._entry(self.F, 4)
项目:pyktrader2    作者:harveywwu    | 项目源码 | 文件源码
def position_view(self):
        params = self.app.get_agent_params(['Positions'])
        positions = params['Positions']
        pos_win   = tk.Toplevel(self)
        pos_frame = ScrolledFrame(pos_win)
        fields = ['gateway', 'inst', 'currlong', 'currshort', 'locklong', 'lockshort', 'ydaylong', 'ydayshort']
        for idx, field in enumerate(fields):
            row_idx = 0
            tk.Label(pos_frame.frame, text = field).grid(row=row_idx, column=idx)
            for gway in positions.keys():
                for inst in positions[gway]:
                    row_idx += 1
                    if field == 'inst':
                        txt = inst
                    elif field == 'gateway':
                        txt = str(gway)
                    else:
                        txt = positions[gway][inst][field]
                    tk.Label(pos_frame.frame, text = txt).grid(row=row_idx, column=idx)
项目:pyktrader2    作者:harveywwu    | 项目源码 | 文件源码
def tradepos_view(self):
        params = self.app.get_agent_params(['Risk.ppos'])
        res = params['Risk']
        sum_risk = {}
        sum_risk['total'] = res['total']
        strat_list = res['strats'].keys()
        for strat_name in strat_list:
            sum_risk[strat_name] = res['strats'][strat_name]
        pos_win   = tk.Toplevel(self)
        tp_frame = ScrolledFrame(pos_win)
        fields = ['inst', 'total'] + strat_list
        for idx, field in enumerate(fields):
            tk.Label(tp_frame.frame, text = field).grid(row=0, column=idx)
            for idy, inst in enumerate(sum_risk['total'].keys()):
                if field == 'inst':
                    txt = inst
                else:
                    inst_risk = sum_risk[field].get(inst, {})
                    txt = str(inst_risk.get('ppos', 0))
                tk.Label(tp_frame.frame, text = txt).grid(row=idy+1, column=idx)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_sashpos(self):
        self.assertRaises(tkinter.TclError, self.paned.sashpos, None)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, '')
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)

        child = ttk.Label(self.paned, text='a')
        self.paned.add(child, weight=1)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)
        child2 = ttk.Label(self.paned, text='b')
        self.paned.add(child2)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 1)

        self.paned.pack(expand=True, fill='both')
        self.paned.wait_visibility()

        curr_pos = self.paned.sashpos(0)
        self.paned.sashpos(0, 1000)
        self.assertNotEqual(curr_pos, self.paned.sashpos(0))
        self.assertIsInstance(self.paned.sashpos(0), int)
项目: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 test_sashpos(self):
        self.assertRaises(tkinter.TclError, self.paned.sashpos, None)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, '')
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)

        child = ttk.Label(self.paned, text='a')
        self.paned.add(child, weight=1)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)
        child2 = ttk.Label(self.paned, text='b')
        self.paned.add(child2)
        self.assertRaises(tkinter.TclError, self.paned.sashpos, 1)

        self.paned.pack(expand=True, fill='both')
        self.paned.wait_visibility()

        curr_pos = self.paned.sashpos(0)
        self.paned.sashpos(0, 1000)
        self.assertNotEqual(curr_pos, self.paned.sashpos(0))
        self.assertIsInstance(self.paned.sashpos(0), int)
项目: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)
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def test_sashpos(self):
        self.assertRaises(Tkinter.TclError, self.paned.sashpos, None)
        self.assertRaises(Tkinter.TclError, self.paned.sashpos, '')
        self.assertRaises(Tkinter.TclError, self.paned.sashpos, 0)

        child = ttk.Label(self.paned, text='a')
        self.paned.add(child, weight=1)
        self.assertRaises(Tkinter.TclError, self.paned.sashpos, 0)
        child2 = ttk.Label(self.paned, text='b')
        self.paned.add(child2)
        self.assertRaises(Tkinter.TclError, self.paned.sashpos, 1)

        self.paned.pack(expand=True, fill='both')
        self.paned.wait_visibility()

        curr_pos = self.paned.sashpos(0)
        self.paned.sashpos(0, 1000)
        self.assertTrue(curr_pos != self.paned.sashpos(0))
        self.assertTrue(isinstance(self.paned.sashpos(0), int))
项目: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)
项目:Enrich2    作者:FowlerLab    | 项目源码 | 文件源码
def body(self, master):
        """
        Generates the required text listing all elements that will be deleted.

        Displays the "OK" and "Cancel" buttons.
        """
        if len(self.id_tuples) == 0:
            message_string = "No elements selected."
        elif len(self.id_tuples) == 1:
            message_string = 'Delete "{}"?'.format(self.tree.get_element(self.id_tuples[0][0]).name)
        else:
            message_string = "Delete the following items?\n"
            for x, level in self.id_tuples:
                if level == 0:
                    bullet = "    " + u"\u25C6"
                else:
                    bullet = "    " * (level + 1) + u"\u25C7"
                message_string += u"{bullet} {name}\n".format(bullet=bullet, name=self.tree.get_element(x).name)
        message = ttk.Label(master, text=message_string, justify="left")
        message.grid(row=0, sticky="w")
项目:Enrich2    作者:FowlerLab    | 项目源码 | 文件源码
def body(self, master):
        """
        Generates the required text listing all SeqLibs that will have their FASTQ options updated.

        Displays the "OK" and "Cancel" buttons.
        """
        if len(self.target_ids) == 0:
            message_string = "No elegible SeqLibs selected."
        elif len(self.target_ids) == 1:
            message_string = 'Apply FASTQ filtering options from "{}" to "{}"?'.format(self.tree.get_element(self.source_id).name, self.tree.get_element(self.target_ids[0]).name)
        else:
            bullet = "    " + u"\u25C6"
            message_string = 'Apply FASTQ filtering options from "{}"" to the following?\n'.format(self.tree.get_element(self.source_id).name)
            for x in self.target_ids:
                message_string += u"{bullet} {name}\n".format(bullet=bullet, name=self.tree.get_element(x).name)
        message = ttk.Label(master, text=message_string, justify="left")
        message.grid(row=0, sticky="w")
项目:metlab    作者:norling    | 项目源码 | 文件源码
def _set_queue(self, queue):
        for child in self.queue.winfo_children():
            child.destroy()

        if queue != ["('None', 'running')"]:
            for item in queue:
                item, status = eval(item)
                item = item.split('/')[-1]
                queue_item = Frame(self.queue)
                item_label = Label(queue_item, text="%s:     %s" % (item, status))
                item_label.pack(side="left", anchor="nw")
                queue_item.pack(side='top', anchor='nw', fill=X)
项目:StochOPy    作者:keurfonluu    | 项目源码 | 文件源码
def frame1_pop(self):
        if not self.frame1.first_run:
            self.frame1.pop.forget()
        self.frame1.pop = ttk.Frame(self.frame1, borderwidth = 0)
        self.frame1.pop.place(width = 170, height = 25, relx = 0.35, y = 30, anchor = "nw")
        if self.solver_name.get() in self.EAOPT:
            # popsize
            popsize_label = ttk.Label(self.frame1.pop, text = "Population size")
            popsize_spinbox = Spinbox(self.frame1.pop, from_ = 1, to_ = 999,
                                      increment = 1, textvariable = self.popsize,
                                      width = 3, justify = "right", takefocus = True)

            # Layout
            popsize_label.place(relx = 0, x = 0, y = 0, anchor = "nw")
            popsize_spinbox.place(width = 60, relx = 0, x = 110, y = 0, anchor = "nw")
项目:StochOPy    作者:keurfonluu    | 项目源码 | 文件源码
def _label(self, text, position, kwargs = {}):
        label = ttk.Label(self.frame1.sliders, text = text, **kwargs)
        if position == 1:
            label.place(relx = 0, x = 0, y = 5, anchor = "nw")
        elif position == 2:
            label.place(relx = 0, x = 0, y = 50, anchor = "nw")
        elif position == 3:
            label.place(relx = 0.5, x = 0, y = 5, anchor = "nw")
        elif position == 4:
            label.place(relx = 0.5, x = 0, y = 50, anchor = "nw")
        return label
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def set_title(self, title):
        ttk.Label(self.mainframe, text=title).grid(column=1, columnspan=4, row=0, sticky=(W,E))
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def add_trace(self):
        ttk.Label(self.mainframe, text="\n".join(self.trace),wraplength=1000).grid(column=5, row=0, rowspan = 5, sticky=N+W)
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def telling(self, phrase):
        for child in self.mainframe.winfo_children():
            child.destroy()
        self.add_emoji()
        self.add_trace()
        ttk.Label(self.mainframe, text=phrase, font=("Comic Sans MS", 20, "italic"), foreground="blue", wraplength=1000).grid(column=1, columnspan=4, row=0, sticky=N+S+E+W)


################################################
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def set_title(self, title):
        ttk.Label(self.mainframe, text=title).grid(column=1, columnspan=4, row=0, sticky=(W,E))
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def add_trace(self):
        ttk.Label(self.mainframe, text="\n".join(self.trace),wraplength=1000).grid(column=5, row=0, rowspan = 5, sticky=N+W)
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def set_title(self, title):
        ttk.Label(self.mainframe, text=title).grid(column=1, columnspan=4, row=0, sticky=(W,E))
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def add_trace(self):
        ttk.Label(self.mainframe, text="\n".join(self.trace),wraplength=1000).grid(column=5, row=0, rowspan = 5, sticky=N+W)
项目:Story_CoWriting    作者:alexis-jacq    | 项目源码 | 文件源码
def telling(self, phrase):
        for child in self.mainframe.winfo_children():
            child.destroy()
        self.add_emoji()
        self.add_trace()
        ttk.Label(self.mainframe, text=phrase, font=("Comic Sans MS", 20, "italic"), foreground="blue", wraplength=1000).grid(column=1, columnspan=4, row=0, sticky=N+S+E+W)


################################################
项目:pyktrader2    作者:harveywwu    | 项目源码 | 文件源码
def qry_agent_histdata(self):
        instfield = 'QryInst'
        ent = self.entries[instfield]
        inst = ent.get()
        freqfield = 'HistFreq'
        fent = self.entries[freqfield]
        freq = fent.get()
        data = self.app.get_hist_data(inst, freq, nlen = 20)
        if len(data) == 0:
            return
        pos_win = tk.Toplevel(self)
        pos_frame = ScrolledFrame(pos_win)
        fields = data.dtype.names
        for idx, field in enumerate(fields):
            row_idx = 0
            tk.Label(pos_frame.frame, text=field).grid(row=row_idx, column=idx)
            for i in range(len(data)):
                row_idx += 1
                txt = data[field][i]
                if type(txt).__name__ == "datetime64":
                    if field == "date":
                        txt = pd.to_datetime(str(txt)).strftime("%Y-%m-%d")
                    else:
                        txt = pd.to_datetime(str(txt)).strftime("%Y-%m-%d %H%M%S")
                elif type(txt).__name__ in ['float', 'float64']:
                    txt = round(txt, 2)
                tk.Label(pos_frame.frame, text=txt).grid(row=row_idx, column=idx)
项目:pyktrader2    作者:harveywwu    | 项目源码 | 文件源码
def show_risks(self, root):
        top_level   = tk.Toplevel(root)
        scr_frame = ScrolledFrame(top_level)
        fields = ['Name', 'Underlying', 'Contract', 'Otype', 'Stike', 'Price', 'BidPrice', 'BidIV', 'AskPrice', 'AskIV', 'PV', 'Delta','Gamma','Vega', 'Theta']
        for idx, field in enumerate(fields):
            tk.Label(scr_frame.frame, text = field).grid(row=0, column=idx)
        idy = 0
        for i, cmth in enumerate(self.cont_mth):
            for strike in self.strikes[i]:
                for otype in ['C','P']:
                    key = (cmth, otype, strike)
                    if key in self.opt_dict:
                        idy += 1
                        inst = self.opt_dict[key]
                        for idx, field in enumerate(fields):
                            if idx == 0:
                                txt = inst
                            elif idx == 1:
                                txt = self.underliers[i]
                            elif idx in [2, 3, 4]: 
                                txt = key[idx-2]
                            else:
                                factor = 1
                                if field in ['delta', 'gamma', 'BidIV', 'AskIV']: 
                                    factor = 100
                                txt = self.curr_insts[inst][field]*factor
                            tk.Label(scr_frame.frame, text = keepdigit(txt,3)).grid(row=idy, column=idx)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_labelwidget(self):
        widget = self.create()
        label = ttk.Label(self.root, text='Mupp', name='foo')
        self.checkParam(widget, 'labelwidget', label, expected='.foo')
        label.destroy()
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Label(self.root, **kwargs)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_add(self):
        # attempt to add a child that is not a direct child of the paned window
        label = ttk.Label(self.paned)
        child = ttk.Label(label)
        self.assertRaises(tkinter.TclError, self.paned.add, child)
        label.destroy()
        child.destroy()
        # another attempt
        label = ttk.Label(self.root)
        child = ttk.Label(label)
        self.assertRaises(tkinter.TclError, self.paned.add, child)
        child.destroy()
        label.destroy()

        good_child = ttk.Label(self.root)
        self.paned.add(good_child)
        # re-adding a child is not accepted
        self.assertRaises(tkinter.TclError, self.paned.add, good_child)

        other_child = ttk.Label(self.paned)
        self.paned.add(other_child)
        self.assertEqual(self.paned.pane(0), self.paned.pane(1))
        self.assertRaises(tkinter.TclError, self.paned.pane, 2)
        good_child.destroy()
        other_child.destroy()
        self.assertRaises(tkinter.TclError, self.paned.pane, 0)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_forget(self):
        self.assertRaises(tkinter.TclError, self.paned.forget, None)
        self.assertRaises(tkinter.TclError, self.paned.forget, 0)

        self.paned.add(ttk.Label(self.root))
        self.paned.forget(0)
        self.assertRaises(tkinter.TclError, self.paned.forget, 0)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_insert(self):
        self.assertRaises(tkinter.TclError, self.paned.insert, None, 0)
        self.assertRaises(tkinter.TclError, self.paned.insert, 0, None)
        self.assertRaises(tkinter.TclError, self.paned.insert, 0, 0)

        child = ttk.Label(self.root)
        child2 = ttk.Label(self.root)
        child3 = ttk.Label(self.root)

        self.assertRaises(tkinter.TclError, self.paned.insert, 0, child)

        self.paned.insert('end', child2)
        self.paned.insert(0, child)
        self.assertEqual(self.paned.panes(), (str(child), str(child2)))

        self.paned.insert(0, child2)
        self.assertEqual(self.paned.panes(), (str(child2), str(child)))

        self.paned.insert('end', child3)
        self.assertEqual(self.paned.panes(),
            (str(child2), str(child), str(child3)))

        # reinserting a child should move it to its current position
        panes = self.paned.panes()
        self.paned.insert('end', child3)
        self.assertEqual(panes, self.paned.panes())

        # moving child3 to child2 position should result in child2 ending up
        # in previous child position and child ending up in previous child3
        # position
        self.paned.insert(child2, child3)
        self.assertEqual(self.paned.panes(),
            (str(child3), str(child2), str(child)))
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def setUp(self):
        super(NotebookTest, self).setUp()
        self.nb = self.create(padding=0)
        self.child1 = ttk.Label(self.root)
        self.child2 = ttk.Label(self.root)
        self.nb.add(self.child1, text='a')
        self.nb.add(self.child2, text='b')
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_add_and_hidden(self):
        self.assertRaises(tkinter.TclError, self.nb.hide, -1)
        self.assertRaises(tkinter.TclError, self.nb.hide, 'hi')
        self.assertRaises(tkinter.TclError, self.nb.hide, None)
        self.assertRaises(tkinter.TclError, self.nb.add, None)
        self.assertRaises(tkinter.TclError, self.nb.add, ttk.Label(self.root),
            unknown='option')

        tabs = self.nb.tabs()
        self.nb.hide(self.child1)
        self.nb.add(self.child1)
        self.assertEqual(self.nb.tabs(), tabs)

        child = ttk.Label(self.root)
        self.nb.add(child, text='c')
        tabs = self.nb.tabs()

        curr = self.nb.index('current')
        # verify that the tab gets readded at its previous position
        child2_index = self.nb.index(self.child2)
        self.nb.hide(self.child2)
        self.nb.add(self.child2)
        self.assertEqual(self.nb.tabs(), tabs)
        self.assertEqual(self.nb.index(self.child2), child2_index)
        self.assertEqual(str(self.child2), self.nb.tabs()[child2_index])
        # but the tab next to it (not hidden) is the one selected now
        self.assertEqual(self.nb.index('current'), curr + 1)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_insert(self):
        # moving tabs
        tabs = self.nb.tabs()
        self.nb.insert(1, tabs[0])
        self.assertEqual(self.nb.tabs(), (tabs[1], tabs[0]))
        self.nb.insert(self.child1, self.child2)
        self.assertEqual(self.nb.tabs(), tabs)
        self.nb.insert('end', self.child1)
        self.assertEqual(self.nb.tabs(), (tabs[1], tabs[0]))
        self.nb.insert('end', 0)
        self.assertEqual(self.nb.tabs(), tabs)
        # bad moves
        self.assertRaises(tkinter.TclError, self.nb.insert, 2, tabs[0])
        self.assertRaises(tkinter.TclError, self.nb.insert, -1, tabs[0])

        # new tab
        child3 = ttk.Label(self.root)
        self.nb.insert(1, child3)
        self.assertEqual(self.nb.tabs(), (tabs[0], str(child3), tabs[1]))
        self.nb.forget(child3)
        self.assertEqual(self.nb.tabs(), tabs)
        self.nb.insert(self.child1, child3)
        self.assertEqual(self.nb.tabs(), (str(child3), ) + tabs)
        self.nb.forget(child3)
        self.assertRaises(tkinter.TclError, self.nb.insert, 2, child3)
        self.assertRaises(tkinter.TclError, self.nb.insert, -1, child3)

        # bad inserts
        self.assertRaises(tkinter.TclError, self.nb.insert, 'end', None)
        self.assertRaises(tkinter.TclError, self.nb.insert, None, 0)
        self.assertRaises(tkinter.TclError, self.nb.insert, None, None)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def _setup_widgets(self):
        msg = ttk.Label(wraplength="4i", justify="left", anchor="n",
            padding=(10, 2, 10, 6),
            text=("Ttk is the new Tk themed widget set. One of the widgets it "
                  "includes is a tree widget, which can be configured to "
                  "display multiple columns of informational data without "
                  "displaying the tree itself. This is a simple way to build "
                  "a listbox that has multiple columns. Clicking on the "
                  "heading for a column will sort the data by that column. "
                  "You can also change the width of the columns by dragging "
                  "the boundary between them."))
        msg.pack(fill='x')

        container = ttk.Frame()
        container.pack(fill='both', expand=True)

        # XXX Sounds like a good support class would be one for constructing
        #     a treeview with scrollbars.
        self.tree = ttk.Treeview(columns=tree_columns, show="headings")
        vsb = ttk.Scrollbar(orient="vertical", command=self.tree.yview)
        hsb = ttk.Scrollbar(orient="horizontal", command=self.tree.xview)
        self.tree.configure(yscrollcommand=vsb.set, xscrollcommand=hsb.set)
        self.tree.grid(column=0, row=0, sticky='nsew', in_=container)
        vsb.grid(column=1, row=0, sticky='ns', in_=container)
        hsb.grid(column=0, row=1, sticky='ew', in_=container)

        container.grid_columnconfigure(0, weight=1)
        container.grid_rowconfigure(0, weight=1)
项目: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 test_labelwidget(self):
        widget = self.create()
        label = ttk.Label(self.root, text='Mupp', name='foo')
        self.checkParam(widget, 'labelwidget', label, expected='.foo')
        label.destroy()
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def create(self, **kwargs):
        return ttk.Label(self.root, **kwargs)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_forget(self):
        self.assertRaises(tkinter.TclError, self.paned.forget, None)
        self.assertRaises(tkinter.TclError, self.paned.forget, 0)

        self.paned.add(ttk.Label(self.root))
        self.paned.forget(0)
        self.assertRaises(tkinter.TclError, self.paned.forget, 0)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_insert(self):
        self.assertRaises(tkinter.TclError, self.paned.insert, None, 0)
        self.assertRaises(tkinter.TclError, self.paned.insert, 0, None)
        self.assertRaises(tkinter.TclError, self.paned.insert, 0, 0)

        child = ttk.Label(self.root)
        child2 = ttk.Label(self.root)
        child3 = ttk.Label(self.root)

        self.assertRaises(tkinter.TclError, self.paned.insert, 0, child)

        self.paned.insert('end', child2)
        self.paned.insert(0, child)
        self.assertEqual(self.paned.panes(), (str(child), str(child2)))

        self.paned.insert(0, child2)
        self.assertEqual(self.paned.panes(), (str(child2), str(child)))

        self.paned.insert('end', child3)
        self.assertEqual(self.paned.panes(),
            (str(child2), str(child), str(child3)))

        # reinserting a child should move it to its current position
        panes = self.paned.panes()
        self.paned.insert('end', child3)
        self.assertEqual(panes, self.paned.panes())

        # moving child3 to child2 position should result in child2 ending up
        # in previous child position and child ending up in previous child3
        # position
        self.paned.insert(child2, child3)
        self.assertEqual(self.paned.panes(),
            (str(child3), str(child2), str(child)))
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_pane(self):
        self.assertRaises(tkinter.TclError, self.paned.pane, 0)

        child = ttk.Label(self.root)
        self.paned.add(child)
        self.assertIsInstance(self.paned.pane(0), dict)
        self.assertEqual(self.paned.pane(0, weight=None),
                         0 if self.wantobjects else '0')
        # newer form for querying a single option
        self.assertEqual(self.paned.pane(0, 'weight'),
                         0 if self.wantobjects else '0')
        self.assertEqual(self.paned.pane(0), self.paned.pane(str(child)))

        self.assertRaises(tkinter.TclError, self.paned.pane, 0,
            badoption='somevalue')
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def setUp(self):
        super(NotebookTest, self).setUp()
        self.nb = self.create(padding=0)
        self.child1 = ttk.Label(self.root)
        self.child2 = ttk.Label(self.root)
        self.nb.add(self.child1, text='a')
        self.nb.add(self.child2, text='b')
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_insert(self):
        # moving tabs
        tabs = self.nb.tabs()
        self.nb.insert(1, tabs[0])
        self.assertEqual(self.nb.tabs(), (tabs[1], tabs[0]))
        self.nb.insert(self.child1, self.child2)
        self.assertEqual(self.nb.tabs(), tabs)
        self.nb.insert('end', self.child1)
        self.assertEqual(self.nb.tabs(), (tabs[1], tabs[0]))
        self.nb.insert('end', 0)
        self.assertEqual(self.nb.tabs(), tabs)
        # bad moves
        self.assertRaises(tkinter.TclError, self.nb.insert, 2, tabs[0])
        self.assertRaises(tkinter.TclError, self.nb.insert, -1, tabs[0])

        # new tab
        child3 = ttk.Label(self.root)
        self.nb.insert(1, child3)
        self.assertEqual(self.nb.tabs(), (tabs[0], str(child3), tabs[1]))
        self.nb.forget(child3)
        self.assertEqual(self.nb.tabs(), tabs)
        self.nb.insert(self.child1, child3)
        self.assertEqual(self.nb.tabs(), (str(child3), ) + tabs)
        self.nb.forget(child3)
        self.assertRaises(tkinter.TclError, self.nb.insert, 2, child3)
        self.assertRaises(tkinter.TclError, self.nb.insert, -1, child3)

        # bad inserts
        self.assertRaises(tkinter.TclError, self.nb.insert, 'end', None)
        self.assertRaises(tkinter.TclError, self.nb.insert, None, 0)
        self.assertRaises(tkinter.TclError, self.nb.insert, None, None)
项目: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()