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


Python Listbox.pack方法代码示例

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


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

示例1: Mjolnir3

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import pack [as 别名]
class Mjolnir3(KRCCModule):
  def __init__(self, root):
    super().__init__()
    self.root = root
    self.exception = None

    self.list_string = StringVar()
    self.listbox = Listbox(root, listvariable=self.list_string,
                           font='TkFixedFont', width=300)

    self.load()

  def establish_connection_and_run(self):
    error = None
    dots = 0
    connection = None
    while not self.terminate:
      try:
        if connection is None:
          connection = krpc.connect(name=self.name)
        self.run_with_connection(connection)
        error = None
        dots = 0
      except Exception as e:
        if error != e.args[0]:
          error = e.args[0]
          print('\n')
          print(traceback.format_exc())
          sys.stdout.write('Retrying...\n')
        if dots > 80:
          dots = 0
          sys.stdout.write('\n')
        sys.stdout.write('.')
        dots += 1
        sys.stdout.flush()
        time.sleep(1)
    if connection is not None:
      connection.close()

  def run_with_connection(self, connection):
    logging.debug('KRPC connection established')
    strategy = PreLaunch(connection)
    while not self.terminate:
      strategy = strategy.update()
      self.list_string.set(tuple(strategy.display()))

  def run(self):
    try:
      self.establish_connection_and_run()
      self.listbox.destroy()
    except RuntimeError:
      # Should only happen when KeyboardInterrupt is thrown in the MainThread.
      pass

  @property
  def name(self):
    return 'Mjolnir 3'

  def load(self):
    self.listbox.pack(side=LEFT, fill=BOTH)
开发者ID:jsartisohn,项目名称:krpc_scripts,代码行数:62,代码来源:mjolnir3.py

示例2: __init__

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import pack [as 别名]
class FileChooser:
    def __init__(self):
        self.filechooser = Tk()
        self.filechooser.geometry('500x500+0+0')
        self.button  = Button(self.filechooser,text="Add Directory",command=self.addDir)
        self.listview = Listbox(self.filechooser)
        self.closebutton = Button(self.filechooser,text="Scan",command=self.Done)
        self.listview.pack(fill="both")
        self.button.pack(fill='x')
        helptext = """Select directories by pressing the "Add Directory" Button, then press Scan.
                        \n When the file tree appears, red text means the file or folder is a duplicate.
                        \n purple means the folder contains duplicates but itself is not a duplicate.
                        \n Double Click on red text entries to view matches"""
        self.instructions = Label(self.filechooser, text=helptext)
        self.instructions.pack(fill='both')
        self.closebutton.pack()


        self.filechooser.mainloop()
    def Done(self):
        self.filechooser.destroy()
    def addDir(self):
        dir = askdirectory()
        if os.path.isdir(dir):
            dirlist.append(dir)
            self.listview.insert('end',str(dir))
开发者ID:bretttjohnson1,项目名称:Duplicate_Discoverer,代码行数:28,代码来源:main.py

示例3: insert_list

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import pack [as 别名]
 def insert_list(self, items):
     frame = self.frame
     frame.pack(fill="y")
     lb = Listbox(frame, selectmode="multiple")
     for i in items:
         lb.insert("end", i)
     lb.pack()
     self.ok_cancel_buttons(call=lambda : self.del_items(lb.curselection()))
开发者ID:Exodus111,项目名称:Projects,代码行数:10,代码来源:mod_items.py

示例4: __init__

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import pack [as 别名]
  def __init__(self, *, multiple_runner_class, input_spec, left_name,
               right_name):
    """Sets up windows and the instance of RunMultipleTimes that will do the actual work."""
    #: The input_spec is an iterable of
    #: :py:class:`farg.core.read_input_spec.SpecificationForOneRun`.
    self.input_spec = input_spec
    #: Class responsible for the actual running multiple times.
    self.multiple_runner_class = multiple_runner_class
    #: Main window
    self.mw = mw = Tk()
    #: Statistics thus far, grouped by input.
    self.stats = AllStats(left_name=left_name, right_name=right_name)

    #: Are we in the process of quitting?
    self.quitting = False

    self.status_label = Label(
        mw, text='Not Started', font=('Times', 20), foreground='#000000')
    self.status_label_text = self.status_label.cget('text')
    self.status_label.pack(side=TOP, expand=True, fill=X)

    #: Has a run started? Used to ensure single run.
    self.run_started = False

    details_frame = Frame(mw)
    details_frame.pack(side=TOP)
    #: listbox on left listing inputs.
    frame = Frame(details_frame)
    scrollbar = Scrollbar(frame, orient=VERTICAL)
    listbox = Listbox(
        frame,
        yscrollcommand=scrollbar.set,
        height=25,
        width=70,
        selectmode=SINGLE)
    scrollbar.config(command=listbox.yview)
    scrollbar.pack(side=RIGHT, fill=Y)
    listbox.pack(side=LEFT, fill=BOTH, expand=1)
    listbox.bind('<ButtonRelease-1>', self.SelectForDisplay, '+')
    frame.pack(side=LEFT)
    self.listbox = listbox
    #: Canvas on right for details
    self.canvas = Canvas(
        details_frame,
        width=kCanvasWidth,
        height=kCanvasHeight,
        background='#FFFFFF')
    self.canvas.pack(side=LEFT)
    #: which input are we displaying the details of?
    self.display_details_for = None

    #: Thread used for running
    self.thread = None
    self.mw.bind('<KeyPress-q>', lambda e: self.Quit())
    self.mw.bind('<KeyPress-r>', lambda e: self.KickOffRun())
    self.Refresher()
    self.mw.after(1000, self.KickOffRun)
开发者ID:amahabal,项目名称:PySeqsee,代码行数:59,代码来源:non_interactive.py

示例5: LabeledListBox

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import pack [as 别名]
class LabeledListBox(Frame):
    def __init__(self, parent, list_model, label_text):
        Frame.__init__(self, parent)

        self._list_model = list_model
        self._list_objects = []
        self._selected_items = []
        scrollbar = Scrollbar(self, orient=VERTICAL)
        Label(self, text=label_text).pack()
        self.listbox = Listbox(self, selectmode=EXTENDED, exportselection=0, yscrollcommand=scrollbar.set, borderwidth=0, highlightthickness=0)
        scrollbar.config(command=self.listbox.yview)
        scrollbar.pack(side=RIGHT, fill=Y)
        self.listbox.pack(side=LEFT, fill=BOTH, expand=1)
        self.listbox.bind('<<ListboxSelect>>', self._on_select)
        self._list_model.list_items_model.add_listener(self._list_items_changed)
        self._list_model.selected_items_model.add_listener(self._selected_items_changed)
        self._update_list_items()

    def _list_items_changed(self, values):
        self._update_list_items()

    def _selected_items_changed(self, values):
        self._update_selected_items()

    def _update_list_items(self):
        values, labels = self._list_model.list_items_model.get_list_values()
        if not values == self._list_objects:
            self._list_objects = []
            self._selected_items = []
            self.listbox.delete(0, END)
            for value, label in zip(values, labels):
                self._list_objects.append(value)
                self.listbox.insert(END, label)
            self._update_selected_items()

    def _update_selected_items(self):
        selected_items = self._list_model.selected_items_model.selected_items
        if not selected_items == self._selected_items:
            self._selected_items = selected_items
            for index, list_item in enumerate(self._list_objects):
                if list_item in selected_items:
                    self.listbox.selection_set(index)

    def _on_select(self, evt):
        visible_selected_indices = self.listbox.curselection()
        for index, list_item in enumerate(self._list_objects):
            if index in visible_selected_indices:
                self._list_model.selected_items_model.select(list_item)
            else:
                self._list_model.selected_items_model.deselect(list_item)
开发者ID:tomdoel,项目名称:pyxnatbrowser,代码行数:52,代码来源:labeledlistbox.py

示例6: PRGListBox

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import pack [as 别名]
class PRGListBox(Frame):
    def __init__(self, master=None,**args):
        Frame.__init__(self, master,**args)
        scrollbar = Scrollbar(self, orient=VERTICAL) #нужен для отображения длинных списков
        scrollbar.unbind("<Key-Up>")
        scrollbar.unbind("<Key-Down>")
        scrollbar.unbind("<Key-Left>")
        scrollbar.unbind("<Key-Right>")
        scrollbar.pack(side=RIGHT, fill=Y)
        
        self.lst = Listbox(self, yscrollcommand=scrollbar.set, bg="grey", selectmode=SINGLE) 
        self.lst.insert(END,"Hide All")
        self.lst.insert(END,"Show All")
        self.lst.select_set(0)
        self.lst.pack(side=LEFT, fill=BOTH, expand=1)
        
        scrollbar.config(command=self.lst.yview)
开发者ID:sergnov,项目名称:PrgViewer,代码行数:19,代码来源:prgWidgets.py

示例7: initUI

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import pack [as 别名]
    def initUI(self):
        self.parent.title("Listbox")
        self.pack(fill=BOTH, expand=1)

        acts = ["Scarlett Johansson", "Rachel Weiss", "Natalie Portman", "Jessica Alba", "Angelina jolie", "Emma Stone", "Sandra Bullock", "Julia Roberts",
        "Jennifer Lawrence", "Mila Kunis", "Jennifer Aniston", "Charlize Theron", "Cameron Diaz", "Nicole Kidman", "Meryl Streep", "Reese Witherspoon"]

        lb = Listbox(self, selectmode="multiple")
        for i in acts:
            lb.insert(END, i)

        lb.bind("<<ListboxSelect>>", self.onSelect)

        lb.pack(pady=15)

        self.var = StringVar()
        self.label = Label(self, text=0, textvariable=self.var)
        self.label.pack()
开发者ID:Exodus111,项目名称:Projects,代码行数:20,代码来源:listbox.py

示例8: __init__

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import pack [as 别名]
class MiniWindow:
    def __init__(self,root,list):
        self.list = list
        self.mini = Toplevel(root)
        self.mini.wm_title("Matches")
        print (root.winfo_screenwidth())
        self.mini.geometry("%dx%d+%d+%d" %(500,200,root.winfo_x()+root.winfo_width(),root.winfo_y()))
        self.filelist = Listbox(self.mini)
        for item in self.list:
            self.filelist.insert('end',str(item))
        self.filelist.bind("<<ListboxSelect>>",self.onClick)
        self.filelist.pack(fill="both")
    def onClick(self,event):
        print(self.filelist.curselection())
        index = int(self.filelist.curselection()[0])
        link = self.list[index]
        filedir = os.path.dirname(link)
        if os.name == 'nt':
            os.startfile(filedir)
        elif os.name == 'posix':
            subprocess.Popen(["xdg-open",filedir])
开发者ID:bretttjohnson1,项目名称:Duplicate_Discoverer,代码行数:23,代码来源:window.py

示例9: MemoryWatcher

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import pack [as 别名]
class MemoryWatcher():
    
    def __init__(self, parent):

        # Window stuff
        self.parent = parent
        self.parent.geometry("200x300")
        self.frame = Frame(parent)

        # List box stuff
        self.index = 2
        self.memory_listener = MemoryListener(self.action)
        self.listbox = Listbox(self.frame)

        # Initialize the UI
        self.initUI()

    def action(self, data):
        mem = data[0]
        val = data[1]
        self.listbox.insert(hex(self.index), ("[" + hex(mem) + "]: " + hex(val)))
        self.index += 1

    def handle_close(self):
        self.memory_listener.unregister()
        self.parent.destroy()

    def initUI(self):

        # Deal with the UI
        self.parent.title("Memory Watcher")
        self.frame.pack(fill=BOTH, expand=1)

        self.listbox.insert(1, "Memory changed: ") 
        self.listbox.pack(fill=BOTH, expand=1)

        # Handle the closing event (unregister the event listener)
        self.parent.protocol("WM_DELETE_WINDOW", self.handle_close)
开发者ID:centip3de,项目名称:DCPU-16,代码行数:40,代码来源:gui.py

示例10: Tenacity2

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import pack [as 别名]
class Tenacity2(KRCCModule):
  def __init__(self, root):
    super().__init__()
    self.arbitrary_list = [
        ('bla', random.uniform(0, 500)),
        ('blub', random.randint(1, 10)),
        ('hurrz', 'yolo'),
        'sploink',
    ]
    self.listbox = Listbox(root)
    self.canvas = Canvas(root)
    self.load()

  def __del__(self):
    self.canvas.destroy()
    self.listbox.destroy()

  def run(self):
    while not self.terminate:
      pass

  def name(self):
    return 'Tenacity 2'

  def load(self):
    for item in self.arbitrary_list:
      insert_item = 'error'
      if type(item) == type(''):
        insert_item = item
      elif type(item) == type(()):
        key = item[0]
        value = '%s' % item[1]
        if type(item[1]) == float:
          value = '%8.3f' % item[1]
        insert_item = '%s: %s' % (key, value)
      self.listbox.insert(END, insert_item)
    self.listbox.pack(side=LEFT, fill=Y)
    self.canvas.pack(side=RIGHT, fill=BOTH, expand=True)
开发者ID:jsartisohn,项目名称:krpc_scripts,代码行数:40,代码来源:tenacity2.py

示例11: __init__

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

	def __init__(self, parent, listEntries, guiPrompt, allowManualFolderSelection, forceFolderOnlyChoosing=False):
		"""
		NOTE: do not call this constructor directly. Use the ListChooserDialog.showDialog function instead.
		"""
		self.forceFolderOnlyChoosing = forceFolderOnlyChoosing

		self.top = tkinter.Toplevel(parent)
		defaultPadding = {"padx":20, "pady":10}

		# Set a description for this dialog (eg "Please choose a game to mod"
		tkinter.Label(self.top, text=guiPrompt).pack()

		# Define the main listbox to hold the choices given by the 'listEntries' parameter
		listboxFrame = tkinter.Frame(self.top)

		# Define a scrollbar and a listbox. The yscrollcommand is so that the listbox can control the scrollbar
		scrollbar = tkinter.Scrollbar(listboxFrame, orient=tkinter.VERTICAL)
		self.listbox = Listbox(listboxFrame, selectmode=tkinter.BROWSE, yscrollcommand=scrollbar.set)

		# Also configure the scrollbar to control the listbox, and pack it
		scrollbar.config(command=self.listbox.yview)
		scrollbar.pack(side=tkinter.RIGHT, fill=tkinter.Y)

		# Setting width to 0 forces auto-resize of listbox see: https://stackoverflow.com/a/26504193/848627
		for item in listEntries:
			self.listbox.insert(tkinter.END, item)
		self.listbox.config(width=0)
		self.listbox.pack(side=tkinter.LEFT, fill=tkinter.BOTH, expand=1)

		# Finally, pack the Frame so its contents are displayed on the dialog
		listboxFrame.pack(**defaultPadding)

		# If the user is allowed to choose a directory manually, add directory chooser button
		if allowManualFolderSelection:
			b2 = tkinter.Button(self.top, text="Choose Folder Manually", command=self.showDirectoryChooser)
			b2.pack(**defaultPadding)

		# Add an 'OK' button. When pressed, the dialog is closed
		b = tkinter.Button(self.top, text="OK", command=self.ok)
		b.pack(**defaultPadding)

		# This variable stores the returned value from the dialog
		self.result = None

	def showDirectoryChooser(self):
		if IS_MAC and not self.forceFolderOnlyChoosing:
			self.result = filedialog.askopenfilename(filetypes=[(None, "com.apple.application")])
		else:
			self.result = filedialog.askdirectory()
		self.top.destroy()

	def ok(self):
		"""
		This function is called when the 'OK' button is pressed. It retrieves the value of the currently selected item,
		then closes the dialog
		:return:
		"""
		selected_value = None

		if len(self.listbox.curselection()) > 0:
			selected_index = self.listbox.curselection()[0]
			selected_value = self.listbox.get(selected_index)

		self.result = selected_value

		self.top.destroy()

	@staticmethod
	def showDialog(rootGUIWindow, choiceList, guiPrompt, allowManualFolderSelection, forceFolderOnlyChoosing=False):
		"""
		Static helper function to show dialog and get a return value. Arguments are the same as constructor
		:param rootGUIWindow: the parent tkinter object of the dialog (can be root window)
		:param choiceList: a list of strings that the user is to choose from
		:param guiPrompt: the description that will be shown on the dialog
		:param allowManualFolderSelection: if true, user is allowed to select a folder manually.
		:return: returns the value the user selected (string), or None if none available
		"""
		d = ListChooserDialog(rootGUIWindow, choiceList, guiPrompt, allowManualFolderSelection, forceFolderOnlyChoosing)
		rootGUIWindow.wait_window(d.top)
		return d.result
开发者ID:07th-mod,项目名称:resources,代码行数:84,代码来源:higurashiInstaller.py

示例12: Example

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import pack [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

示例13: ProblemBrowser

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import pack [as 别名]
class ProblemBrowser(object):
    def __init__(self):
        self.action = None
        self.root = root = Tk()
        root.title('Never gonna fold you up')
        root.protocol("WM_DELETE_WINDOW", self.close)

        root.pack_propagate(True)

        scrollbar = Scrollbar(root, orient=tkinter.VERTICAL)
        self.problem_list = Listbox(root, exportselection=False, yscrollcommand=scrollbar.set)
        self.problem_list.pack(expand=True, fill=tkinter.BOTH, side=tkinter.LEFT)
        scrollbar.config(command=self.problem_list.yview)
        scrollbar.pack(side=tkinter.LEFT, fill=tkinter.Y)
        self.problem_list.bind('<<ListboxSelect>>', lambda evt: self.populate_problem_canvas())

        self.problem_canvas = Canvas(root, bd=1, relief=tkinter.SUNKEN, width=500, height=500)
        self.problem_canvas.pack(expand=True, fill=tkinter.BOTH, side=tkinter.LEFT)
        self.problem_canvas.bind("<Configure>", lambda evt: self.populate_problem_canvas())

        button_frame = Frame(root)
        button_frame.pack(fill=tkinter.Y, side=tkinter.LEFT)

        # Reposition the figure so it's center of mass is at 0.5, 0.5
        v = IntVar()
        self.center_cb = Checkbutton(button_frame, text="center", variable=v, command=lambda: self.populate_problem_canvas())
        self.center_cb.var = v
        self.center_cb.pack(side=tkinter.TOP)

        # Use meshes.reconstruct_facets instead of polygon/hole logic.
        v = IntVar()
        self.reconstruct_cb = Checkbutton(button_frame, text="reconstruct", variable=v, command=lambda: self.populate_problem_canvas())
        self.reconstruct_cb.var = v
        self.reconstruct_cb.pack(side=tkinter.TOP)

        self.populate_problems()
        self.current_problem_name = None
        self.current_problem = None


    def populate_problems(self):
        self.problem_list.delete(0, tkinter.END)
        for file in sorted((get_root() / 'problems').iterdir()):
            self.problem_list.insert(tkinter.END, file.stem)


    def populate_problem_canvas(self):
        sel = self.problem_list.curselection()
        if not sel: return
        assert len(sel) == 1
        name = self.problem_list.get(sel[0])
        if name != self.current_problem_name:
            self.current_problem_name = name
            self.current_problem = load_problem(name)
        if self.current_problem:
            p = self.current_problem
            if self.center_cb.var.get():
                p = center_problem(p)
            if self.reconstruct_cb.var.get():
                facets = meshes.reconstruct_facets(p)
                facets = meshes.keep_real_facets(facets, p)
                skeleton = [e for f in facets for e in edges_of_a_facet(f)]
                p = Problem(facets, skeleton)
            draw_problem(self.problem_canvas, p)


    def run(self):
        self.root.mainloop()

    def close(self):
        if self.root:
            self.root.destroy()
            self.root = None
开发者ID:Vlad-Shcherbina,项目名称:icfpc2016-tbd,代码行数:75,代码来源:tkrender.py

示例14: LucteriosMainForm

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import pack [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

示例15: ChatGUI

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import pack [as 别名]
class ChatGUI(Frame):
    
    def __init__(self, parent, conn, title):
        #Frame.__init__(self, parent, background="grey")   
         
        self.parent = parent
        self.conn = conn
        self.title = title
        
        self.centerWindow()
        self.initUI()
    
    def initUI(self):
      
        self.lineCounter = 0
      
        # create a custom font
        self.customFontHeader = font.Font(family="Calibri", slant = "italic") #family="Helvetica", weight="bold", slant="italic")
        self.customFontMessage = font.Font(family="Calibri")
        
        self.parent.title(self.title) 
        
        frame = Frame(self.parent)
        frame.pack(fill=BOTH, expand=1, side=LEFT)
        
        self.box = ScrolledText(frame, wrap=WORD, relief = GROOVE, width=30, height=18, font=self.customFontMessage)
        self.box.insert(END, 'Welcome to Python Chat!')
        self.box.config(state=DISABLED)
        self.box.pack(expand="yes", fill=BOTH, side=TOP)
        
        self.textarea = Text(frame, width=30, height=5)
        #self.textarea.insert(END, "")
        self.textarea.bind("<KeyRelease-Return>", self.gettext) #Se metto on press, rimane una newline in piu
        self.textarea.pack(expand="yes", fill=BOTH, side=TOP)

        
        okButton = Button(frame, text="Panic Button", activebackground="red", command=self.sendFile) 
        okButton.pack(expand="no", fill=BOTH, side=TOP)
        
        self.usersFrame = Frame(self.parent)
        self.usersFrame.pack(fill=BOTH, expand=1, side=RIGHT)
        
        self.userListbox = Listbox(self.usersFrame, width=3)
        self.userListbox.bind("<Double-Button-1>", self.privateChat)
        self.userListbox.pack(fill=BOTH, expand=1)
            
        self.updateUsersFrame()
        
    def centerWindow(self):
      
        w = 600
        h = 475

        sw = self.parent.winfo_screenwidth()
        sh = self.parent.winfo_screenheight()
        
        x = (sw - w)/2
        y = (sh - h)/2
        self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y))
     
    def gettext(self, e): #e sta per event, questo e' un listener
        text = self.textarea.get("1.0", END + " - 2c") # 1.0: row:columa -  END-2c rimuove l'ultimo carattere, una newline \r\n
        self.textarea.delete("0.0", END) #NON VA: il problema e' che viene inviato il carattere di newline ma non incluso nell'area a causa della bind mi sa. Devo escluderlo io
        self.sendToServer(text)
        
    def printConversation(self, message):
        self.box.config(state=NORMAL)
        self.box.insert(END,"\n" + message)
        self.lineCounter = self.lineCounter + 2
        
        #m = re.match("\[.*\] From .*\n", self.box.get("0.0", END))
        m = re.search("\[.*\].*:", message, re.MULTILINE)
        
        
        if m is not None:
            #print("MATCH")
            #print(m.group(0))
            #print(str(m.start(0)) + "_" + str(m.end(0)))
            #print("COUNTER")
            #print(str(self.lineCounter) + "." + str(m.start(0)+1) + "___" + str(self.lineCounter) + "." + str(m.end(0)))
            self.box.tag_add("header", str(self.lineCounter) + "." + str(m.start(0)), str(self.lineCounter) + "." + str(m.end(0)))
            self.box.tag_config("header", font=self.customFontHeader, foreground = "blue")
        
        
        self.box.config(state=DISABLED)
        #self.box.yview_scroll(10000,"units")
        self.box.see(END)

    
    def sendToServer(self, messageToSend):
        self.conn.send(messageToSend.encode(encoding='utf_8', errors='strict'))
    
    def sendFile(self):
        #aprire una dialog di quelle predefinite (Sfoglia...)
        #capire come fare la send di un file sul socket...
        pass
    def updateUsersFrame(self):
        
        global connectedClients
    
#.........这里部分代码省略.........
开发者ID:skimdz86,项目名称:Utilities,代码行数:103,代码来源:BlinkingChatGUIMultiClient.py


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