当前位置: 首页>>代码示例>>Python>>正文


Python Listbox.size方法代码示例

本文整理汇总了Python中tkinter.Listbox.size方法的典型用法代码示例。如果您正苦于以下问题:Python Listbox.size方法的具体用法?Python Listbox.size怎么用?Python Listbox.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tkinter.Listbox的用法示例。


在下文中一共展示了Listbox.size方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Example

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import size [as 别名]
class Example(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent, background="#8080FF")
        self.parent = parent
        self.initUI()

    def initUI(self):
        self.parent.title("EQ GuildViewer 0.1")

        fontb = Font(size=12, weight="bold")

        # inicializo variables
        self.ant = None
        self.lastLine = 0
        self.name = ""

        # frame padre
        area = Frame(self)
        area.pack(side=BOTTOM, fill=BOTH, expand=1)

        areab = Frame(self)
        areab.pack(side=TOP, fill=BOTH, expand=1)

        # scroll players
        self.scrollbar2 = Scrollbar(areab, orient=VERTICAL)

        # construimos un menu con todos los nombres del diccionario y un boton
        self.refreshButton = Button(areab, text="""PARSEA!""", command=self.onRefresh, bd=2, relief="groove")
        self.listboxLogs = Listbox(
            areab, width=50, activestyle="none", highlightthickness=0, yscrollcommand=self.scrollbar2.set, relief=RIDGE
        )
        self.listboxLogs.pack(side=LEFT, fill=Y)
        self.scrollbar2.pack(side=LEFT, fill=Y)
        self.refreshButton.pack(side=LEFT, fill=BOTH, expand=1)

        for player in optionsDictionary:
            self.listboxLogs.insert(END, player)

        # scroll
        self.scrollbar = Scrollbar(area, orient=VERTICAL)
        self.scrollbar.pack(side=RIGHT, fill=Y)

        # area1
        area1 = Frame(area)
        area1.pack(side=LEFT, fill=Y)

        lbl = Label(area1, text="Name")
        self.listbox = Listbox(
            area1, yscrollcommand=self.scrollbar.set, font=fontb, relief=FLAT, highlightthickness=0, activestyle="none"
        )
        lbl.pack(side=TOP)
        self.listbox.pack(side=BOTTOM, fill=Y, expand=1)

        # area2
        area2 = Frame(area)
        area2.pack(side=LEFT, fill=Y)

        lbl2 = Label(area2, text="Level")
        self.listbox2 = Listbox(
            area2, yscrollcommand=self.scrollbar.set, font=fontb, relief=FLAT, highlightthickness=0, activestyle="none"
        )
        lbl2.pack(side=TOP)
        self.listbox2.pack(side=BOTTOM, fill=Y, expand=1)

        # area3
        area3 = Frame(area)
        area3.pack(side=LEFT, fill=Y)

        lbl3 = Label(area3, text="Class")
        self.listbox3 = Listbox(
            area3, yscrollcommand=self.scrollbar.set, font=fontb, relief=FLAT, highlightthickness=0, activestyle="none"
        )
        lbl3.pack(side=TOP)
        self.listbox3.pack(side=BOTTOM, fill=Y, expand=1)

        # area4
        area4 = Frame(area)
        area4.pack(side=LEFT, fill=Y)

        lbl4 = Label(area4, text="Race")
        self.listbox4 = Listbox(
            area4, yscrollcommand=self.scrollbar.set, font=fontb, relief=FLAT, highlightthickness=0, activestyle="none"
        )
        lbl4.pack(side=TOP)
        self.listbox4.pack(side=BOTTOM, fill=Y, expand=1)

        # area3
        area5 = Frame(area)
        area5.pack(side=LEFT, fill=Y)

        lbl5 = Label(area5, text="Zone")
        self.listbox5 = Listbox(
            area5, yscrollcommand=self.scrollbar.set, font=fontb, relief=FLAT, highlightthickness=0, activestyle="none"
        )
        lbl5.pack(side=TOP)
        self.listbox5.pack(side=BOTTOM, fill=Y, expand=1)

        self.pack(fill=BOTH, expand=1)

        # config-scrollbar
#.........这里部分代码省略.........
开发者ID:Ealdor,项目名称:EQGuildViewer,代码行数:103,代码来源:GuildViewer.py

示例2: __init__

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import size [as 别名]

#.........这里部分代码省略.........
            for i in range(0, self._current_layer.get_polygon_count()):
                if self._current_layer.get_polygon_at(i).contains(x, y):
                    self._current_layer.remove_polygon_at(i)
                    break

        self._canvas.notify_layer_change()

    def _canvas_mouse_moved(self, event):
        if self._is_drawing_polygon:
            x, y = self._canvas.window_to_canvas_coords(event.x, event.y)
            self._current_layer.get_polygon_at(-1).get_vertex_at(-1)\
                .set_coords(x, y)
            self._canvas.notify_polygon_change(self._current_layer
                                               .get_polygon_count()-1)

    def _layer_change(self, event):
        selection = self._layer_list.curselection()
        if len(selection) > 0 and self._scene:
            layer = self._scene.get_layer_at(selection[0])
            if layer:
                self._is_drawing_polygon = False
                self._current_layer = layer
                self._canvas.notify_new_layer(self._current_layer)

    def _set_scene(self, scene: Scene) -> bool:
        if scene.get_layer_count() <= 0:
            messagebox.showerror("Error!", "Scene has no layers!")
            return False

        self._scene = scene

        # Prepare canvas
        # TODO Extra 10px padding for canvas
        width, height = self._scene.get_size()
        self._canvas.config(scrollregion=(0, 0, width, height))

        # Empty listbox, fill it, select first entry
        self._layer_list.delete(0, self._layer_list.size()-1)
        for i in range(0, self._scene.get_layer_count()):
            self._layer_list.insert(i, self._scene.get_layer_at(i).get_name())
        self._layer_list.selection_set(0)
        self._layer_list.event_generate("<<ListboxSelect>>")

        return True

    def _set_current_path(self, path):
        self._current_path = path
        if path:
            self._tk.title(path + " - Layered Polygons")
        else:
            self._tk.title("Untitled - Layered Polygons")

    def _new_scene(self):
        path = filedialog.askopenfilename(defaultextension=".ora",
                                          filetypes=[("OpenRaster files",
                                                      ".ora")])
        if not path:
            return

        scene = ora.read(path)
        if not scene:
            messagebox.showerror("Error!", "File could not be opened!")
            return

        if self._set_scene(scene):
            self._set_current_path(None)
开发者ID:tobchen,项目名称:LayeredPolygons,代码行数:70,代码来源:controller.py

示例3: LucteriosMainForm

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import size [as 别名]
class LucteriosMainForm(Tk):

    def __init__(self):
        Tk.__init__(self)
        try:
            img = Image("photo", file=join(
                dirname(import_module('lucterios.install').__file__), "lucterios.png"))
            self.tk.call('wm', 'iconphoto', self._w, img)
        except:
            pass
        self.has_checked = False
        self.title(ugettext("Lucterios installer"))
        self.minsize(475, 260)
        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(0, weight=1)
        self.running_instance = {}
        self.resizable(True, True)
        self.protocol("WM_DELETE_WINDOW", self.on_closing)

        self.ntbk = ttk.Notebook(self)
        self.ntbk.grid(row=0, column=0, columnspan=1, sticky=(N, S, E, W))

        self.create_instance_panel()
        self.create_module_panel()

        stl = ttk.Style()
        stl.theme_use("default")
        stl.configure("TProgressbar", thickness=5)
        self.progress = ttk.Progressbar(
            self, style="TProgressbar", orient='horizontal', mode='indeterminate')
        self.progress.grid(row=1, column=0, sticky=(E, W))

        self.btnframe = Frame(self, bd=1)
        self.btnframe.grid(row=2, column=0, columnspan=1)
        Button(self.btnframe, text=ugettext("Refresh"), width=20, command=self.refresh).grid(
            row=0, column=0, padx=3, pady=3, sticky=(N, S))
        self.btnupgrade = Button(
            self.btnframe, text=ugettext("Search upgrade"), width=20, command=self.upgrade)
        self.btnupgrade.config(state=DISABLED)
        self.btnupgrade.grid(row=0, column=1, padx=3, pady=3, sticky=(N, S))
        Button(self.btnframe, text=ugettext("Close"), width=20, command=self.on_closing).grid(
            row=0, column=2, padx=3, pady=3, sticky=(N, S))

    def on_closing(self):
        all_stop = True
        instance_names = list(self.running_instance.keys())
        for old_item in instance_names:
            if (self.running_instance[old_item] is not None) and self.running_instance[old_item].is_running():
                all_stop = False
        if all_stop or askokcancel(None, ugettext("An instance is always running.\nDo you want to close?")):
            self.destroy()
        else:
            self.refresh()

    def destroy(self):
        instance_names = list(self.running_instance.keys())
        for old_item in instance_names:
            if self.running_instance[old_item] is not None:
                self.running_instance[old_item].stop()
                del self.running_instance[old_item]
        Tk.destroy(self)

    def create_instance_panel(self):
        frm_inst = Frame(self.ntbk)
        frm_inst.grid_columnconfigure(0, weight=1)
        frm_inst.grid_rowconfigure(0, weight=1)
        frm_inst.grid_columnconfigure(1, weight=3)
        frm_inst.grid_rowconfigure(1, weight=0)
        self.instance_list = Listbox(frm_inst, width=20)
        self.instance_list.bind('<<ListboxSelect>>', self.select_instance)
        self.instance_list.pack()
        self.instance_list.grid(row=0, column=0, sticky=(N, S, W, E))

        self.instance_txt = Text(frm_inst, width=75)
        self.instance_txt.grid(row=0, column=1, rowspan=2, sticky=(N, S, W, E))
        self.instance_txt.config(state=DISABLED)

        self.btninstframe = Frame(frm_inst, bd=1)
        self.btninstframe.grid(row=1, column=0, columnspan=1)
        self.btninstframe.grid_columnconfigure(0, weight=1)
        Button(self.btninstframe, text=ugettext("Launch"), width=25, command=self.open_inst).grid(
            row=0, column=0, columnspan=2, sticky=(N, S))
        Button(self.btninstframe, text=ugettext("Modify"), width=10,
               command=self.modify_inst).grid(row=1, column=0, sticky=(N, S))
        Button(self.btninstframe, text=ugettext("Delete"), width=10,
               command=self.delete_inst).grid(row=1, column=1, sticky=(N, S))
        Button(self.btninstframe, text=ugettext("Save"), width=10,
               command=self.save_inst).grid(row=2, column=0, sticky=(N, S))
        Button(self.btninstframe, text=ugettext("Restore"), width=10,
               command=self.restore_inst).grid(row=2, column=1, sticky=(N, S))
        Button(self.btninstframe, text=ugettext("Add"), width=25, command=self.add_inst).grid(
            row=3, column=0, columnspan=2, sticky=(N, S))

        self.ntbk.add(frm_inst, text=ugettext('Instances'))

    def create_module_panel(self):
        frm_mod = Frame(self.ntbk)
        frm_mod.grid_columnconfigure(0, weight=1)
        frm_mod.grid_rowconfigure(0, weight=1)
        self.module_txt = Text(frm_mod)
#.........这里部分代码省略.........
开发者ID:povtux,项目名称:core,代码行数:103,代码来源:lucterios_gui.py

示例4: InstanceEditor

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import size [as 别名]

#.........这里部分代码省略.........
              ).grid(row=4, column=0, sticky=(N, W), padx=5, pady=3)
        self.mode = ttk.Combobox(
            self.frm_general, textvariable=StringVar(), state=READLONY)
        self.mode.bind("<<ComboboxSelected>>", self.mode_selection)
        self.mode.grid(row=4, column=1, sticky=(N, S, E, W), padx=5, pady=3)
        Label(self.frm_general, text=ugettext("Password")).grid(
            row=5, column=0, sticky=(N, W), padx=5, pady=3)
        self.password = Entry(self.frm_general, show="*")
        self.password.grid(
            row=5, column=1, sticky=(N, S, E, W), padx=5, pady=3)

    def typedb_selection(self, event):

        visible = list(self.typedb[VALUES]).index(self.typedb.get()) != 0
        for child_cmp in self.frm_database.winfo_children()[2:]:
            if visible:
                child_cmp.config(state=NORMAL)
            else:
                child_cmp.config(state=DISABLED)

    def appli_selection(self, event):
        if self.applis.get() != '':
            appli_id = list(self.applis[VALUES]).index(self.applis.get())
            luct_glo = LucteriosGlobal()
            current_inst_names = luct_glo.listing()
            appli_root_name = self.mod_applis[appli_id][0].split('.')[-1]
            default_name_idx = 1
            while appli_root_name + six.text_type(default_name_idx) in current_inst_names:
                default_name_idx += 1
            self.name.delete(0, END)
            self.name.insert(
                0, appli_root_name + six.text_type(default_name_idx))
            mod_depended = self.mod_applis[appli_id][2]
            self.modules.select_clear(0, self.modules.size())
            for mod_idx in range(len(self.module_data)):
                current_mod = self.module_data[mod_idx]
                if current_mod in mod_depended:
                    self.modules.selection_set(mod_idx)

    def mode_selection(self, event):
        visible = list(self.mode[VALUES]).index(self.mode.get()) != 2
        for child_cmp in self.frm_general.winfo_children()[-2:]:
            if visible:
                child_cmp.config(state=NORMAL)
            else:
                child_cmp.config(state=DISABLED)

    def apply(self):
        from lucterios.framework.settings import DEFAULT_LANGUAGES, get_locale_lang
        if self.name.get() == '':
            showerror(ugettext("Instance editor"), ugettext("Name empty!"))
            return
        if self.applis.get() == '':
            showerror(ugettext("Instance editor"), ugettext("No application!"))
            return
        db_param = "%s:name=%s,user=%s,password=%s" % (
            self.typedb.get(), self.namedb.get(), self.userdb.get(), self.pwddb.get())
        security = "MODE=%s" % list(
            self.mode[VALUES]).index(self.mode.get())
        if self.password.get() != '':
            security += ",PASSWORD=%s" % self.password.get()
        module_list = [
            self.module_data[int(item)] for item in self.modules.curselection()]
        appli_id = list(self.applis[VALUES]).index(self.applis.get())
        current_lang = get_locale_lang()
        for lang in DEFAULT_LANGUAGES:
开发者ID:povtux,项目名称:core,代码行数:70,代码来源:lucterios_gui.py

示例5: DrtGlueDemo

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import size [as 别名]
class DrtGlueDemo(object):
    def __init__(self, examples):
        # Set up the main window.
        self._top = Tk()
        self._top.title("DRT Glue Demo")

        # Set up key bindings.
        self._init_bindings()

        # Initialize the fonts.self._error = None
        self._init_fonts(self._top)

        self._examples = examples
        self._readingCache = [None for example in examples]

        # The user can hide the grammar.
        self._show_grammar = IntVar(self._top)
        self._show_grammar.set(1)

        # Set the data to None
        self._curExample = -1
        self._readings = []
        self._drs = None
        self._drsWidget = None
        self._error = None

        self._init_glue()

        # Create the basic frames.
        self._init_menubar(self._top)
        self._init_buttons(self._top)
        self._init_exampleListbox(self._top)
        self._init_readingListbox(self._top)
        self._init_canvas(self._top)

        # Resize callback
        self._canvas.bind("<Configure>", self._configure)

    #########################################
    ##  Initialization Helpers
    #########################################

    def _init_glue(self):
        tagger = RegexpTagger(
            [
                ("^(David|Mary|John)$", "NNP"),
                ("^(walks|sees|eats|chases|believes|gives|sleeps|chases|persuades|tries|seems|leaves)$", "VB"),
                ("^(go|order|vanish|find|approach)$", "VB"),
                ("^(a)$", "ex_quant"),
                ("^(every)$", "univ_quant"),
                ("^(sandwich|man|dog|pizza|unicorn|cat|senator)$", "NN"),
                ("^(big|gray|former)$", "JJ"),
                ("^(him|himself)$", "PRP"),
            ]
        )

        depparser = MaltParser(tagger=tagger)
        self._glue = DrtGlue(depparser=depparser, remove_duplicates=False)

    def _init_fonts(self, root):
        # See: <http://www.astro.washington.edu/owen/ROTKFolklore.html>
        self._sysfont = Font(font=Button()["font"])
        root.option_add("*Font", self._sysfont)

        # TWhat's our font size (default=same as sysfont)
        self._size = IntVar(root)
        self._size.set(self._sysfont.cget("size"))

        self._boldfont = Font(family="helvetica", weight="bold", size=self._size.get())
        self._font = Font(family="helvetica", size=self._size.get())
        if self._size.get() < 0:
            big = self._size.get() - 2
        else:
            big = self._size.get() + 2
        self._bigfont = Font(family="helvetica", weight="bold", size=big)

    def _init_exampleListbox(self, parent):
        self._exampleFrame = listframe = Frame(parent)
        self._exampleFrame.pack(fill="both", side="left", padx=2)
        self._exampleList_label = Label(self._exampleFrame, font=self._boldfont, text="Examples")
        self._exampleList_label.pack()
        self._exampleList = Listbox(
            self._exampleFrame,
            selectmode="single",
            relief="groove",
            background="white",
            foreground="#909090",
            font=self._font,
            selectforeground="#004040",
            selectbackground="#c0f0c0",
        )

        self._exampleList.pack(side="right", fill="both", expand=1)

        for example in self._examples:
            self._exampleList.insert("end", ("  %s" % example))
        self._exampleList.config(height=min(len(self._examples), 25), width=40)

        # Add a scrollbar if there are more than 25 examples.
        if len(self._examples) > 25:
#.........这里部分代码省略.........
开发者ID:BRISATECH,项目名称:ResumeManagementTool,代码行数:103,代码来源:drt_glue_demo.py

示例6: __init__

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import size [as 别名]

#.........这里部分代码省略.........
        )
        msgCat = Radiobutton(
            radio_frame,
            text="Messages by category",
            variable=self.box,
            value="Messages by category",
            command=self.refresh_results_window,
        )
        msg = Radiobutton(
            radio_frame, text="Messages", variable=self.box, value="Messages", command=self.refresh_results_window
        )
        report.select()
        report.grid(column=0, row=0, sticky=W)
        rawMet.grid(column=1, row=0, sticky=W)
        dup.grid(column=2, row=0, sticky=W)
        msg.grid(column=3, row=0, sticky=E)
        stat.grid(column=0, row=1, sticky=W)
        msgCat.grid(column=1, row=1, sticky=W)
        ext.grid(column=2, row=1, columnspan=2, sticky=W)

        # dictionary for check boxes and associated error term
        self.msg_type_dict = {
            "I": lambda: self.information_box.get() == 1,
            "C": lambda: self.convention_box.get() == 1,
            "R": lambda: self.refactor_box.get() == 1,
            "E": lambda: self.error_box.get() == 1,
            "W": lambda: self.warning_box.get() == 1,
            "F": lambda: self.fatal_box.get() == 1,
        }
        self.txtModule.focus_set()

    def select_recent_file(self, event):
        """adds the selected file in the history listbox to the Module box"""
        if not self.showhistory.size():
            return

        selected = self.showhistory.curselection()
        item = self.showhistory.get(selected)
        # update module
        self.txtModule.delete(0, END)
        self.txtModule.insert(0, item)

    def refresh_msg_window(self):
        """refresh the message window with current output"""
        # clear the window
        self.lbMessages.delete(0, END)
        for msg in self.msgs:
            if self.msg_type_dict.get(msg[0])():
                msg_str = self.convert_to_string(msg)
                self.lbMessages.insert(END, msg_str)
                fg_color = COLORS.get(msg_str[:3], "black")
                self.lbMessages.itemconfigure(END, fg=fg_color)

    def refresh_results_window(self):
        """refresh the results window with current output"""
        # clear the window
        self.results.delete(0, END)
        try:
            for res in self.tabs[self.box.get()]:
                self.results.insert(END, res)
        except:
            pass

    def convert_to_string(self, msg):
        """make a string representation of a message"""
        if msg[2] != "":
开发者ID:OFFIS-Automation,项目名称:Framework,代码行数:70,代码来源:gui.py

示例7: TextSelect

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import size [as 别名]
class TextSelect(Frame):

    def __init__(self, client, anchor, items, destroyAnchor=False):
        """
        Args:
            client: [SelectionClient] The window that text is returned to.
            anchor: A window that the text selection popup is created
                relative to.
            items: [str], items to display in the listbox.
            destroyAnchor: [bool] if true, destroy the anchor after
                positioning the window.
        """
        self.top = Toplevel()
        self.anchor = anchor
        self.top.overrideredirect(1)
        self.top.wm_geometry('+%s+%s' % (anchor.winfo_rootx() + anchor.winfo_x(),
                                         anchor.winfo_rooty() + anchor.winfo_y()
                                         )
                             )
        super(TextSelect, self).__init__(self.top)
        self.entry = Entry(self)
        self.client = client
        self.items = items
        self.place(x = 0.5, y = 0.5, height = 100, width = 100)
        self.entry.bind('<Return>', self.close)
        self.entry.bind('<KeyPress>', self.filter)
        self.entry.bind('<Escape>', self.abort)
        self.entry.bind('<Up>', self.up)
        self.entry.bind('<Down>', self.down)
        self.entry.pack()

        # Create the list of items.
        self.list = Listbox(self)
        for item in self.items:
            self.list.insert('end', item)
        self.list.pack()
        self.grid()
        self.entry.focus()

        # Reposition the select button against the anchor.  We defer this
        # until after idle so that the anchor has a chance to get rendered.
        def reposition(*args):
            self.top.wm_geometry('+%s+%s' % (
                anchor.winfo_rootx(),
                anchor.winfo_rooty())
            )
            if destroyAnchor:
                anchor.destroy()
        self.after_idle(reposition)

    def close(self, event):
        sel = self.list.curselection()
        if sel:
            item = self.list.get(sel[0])
        else:
            item = self.entry.get()

        # Note that the order of this appears to be significant: destroying
        # before selecting leaves the focus in a weird state.
        self.client.selected(item)
        self.top.destroy()
        return 'braek'

    def abort(self, event):
        self.top.destroy()
        self.client.aborted()
        return 'break'

    def up(self, event):
        sel = self.list.curselection()
        if not sel:
            self.list.selection_set(0)
            return 'break'
        sel = sel[0]

        print('sel is %s size is %s' % (sel, self.list.size()))
        if sel > 0:
            print('setting selection to %s' % sel)
            self.list.selection_clear(sel)
            self.list.selection_set(sel - 1)
            self.list.see(sel)
        return 'break'

    def down(self, event):
        sel = self.list.curselection()
        if not sel:
            self.list.selection_set(0)
            return 'break'
        sel = sel[0]

        print('sel is %s size is %s' % (sel, self.list.size()))
        if sel < self.list.size() - 1:
            print('setting selection to %s' % (sel + 1))
            self.list.selection_clear(sel)
            self.list.selection_set(sel + 1)
            self.list.see(sel)
        return 'break'

    def filter(self, event):
        """Filter the listbox based on the contents of the entryfield."""
#.........这里部分代码省略.........
开发者ID:mindhog,项目名称:mawb,代码行数:103,代码来源:tkui.py


注:本文中的tkinter.Listbox.size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。