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


Python Scrollbar.pack方法代码示例

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


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

示例1: CimReadme

# 需要导入模块: from tkinter.ttk import Scrollbar [as 别名]
# 或者: from tkinter.ttk.Scrollbar import pack [as 别名]
class CimReadme(Toplevel):
    def __init__(self, parent):
        Toplevel.__init__(self, parent)
        self.configure(borderwidth=0)
        self.geometry("+%d+%d" % (
                        parent.winfo_rootx()+30,
                        parent.winfo_rooty()+30))

        self.vbar = Scrollbar(self)
        self.text = Text(self, wrap='word', borderwidth='0p')
        self.vbar['command'] = self.text.yview
        self.vbar.pack(side=RIGHT, fill='y')
        self.text['yscrollcommand'] = self.vbar.set
        self.text.pack(expand=1, fill="both")
        try:
            f = open(README_PATH)
            self.text.delete(1.0)
            self.text.insert(1.0, f.read())
            self.text.delete('end - 1 chars')
        except:
            showerror("Error", "Cannot load README!")
        self.text.config(state='disabled')

        self.title('README')
        self.protocol("WM_DELETE_WINDOW", self.close)
        self.parent = parent
        self.bind('<Escape>', self.close)

    def close(self, event=None):
        self.destroy()

    def show(parent):
        dlg = CimReadme(parent)
        dlg.lift()
        dlg.focus_set()
开发者ID:ZanderBrown,项目名称:Tiborcim,代码行数:37,代码来源:cim.py

示例2: TextViewer

# 需要导入模块: from tkinter.ttk import Scrollbar [as 别名]
# 或者: from tkinter.ttk.Scrollbar import pack [as 别名]
class TextViewer(Toplevel):
    "A simple text viewer dialog for IDLE."

    def __init__(self, parent, title, text, modal=True,
                 _htest=False, _utest=False):
        """Show the given text in a scrollable window with a 'close' button.

        If modal is left True, users cannot interact with other windows
        until the textview window is closed.

        _htest - bool; change box location when running htest.
        _utest - bool; don't wait_window when running unittest.
        """
        Toplevel.__init__(self, parent)
        self.configure(borderwidth=5)
        # Place dialog below parent if running htest.
        self.geometry("=%dx%d+%d+%d" % (750, 500,
                           parent.winfo_rootx() + 10,
                           parent.winfo_rooty() + (10 if not _htest else 100)))
        # TODO: get fg/bg from theme.
        self.bg = '#ffffff'
        self.fg = '#000000'

        self.CreateWidgets()
        self.title(title)
        self.protocol("WM_DELETE_WINDOW", self.Ok)
        self.parent = parent
        self.textView.focus_set()
        # Bind keys for closing this dialog.
        self.bind('<Return>',self.Ok)
        self.bind('<Escape>',self.Ok)
        self.textView.insert(0.0, text)
        self.textView.config(state=DISABLED)

        if modal:
            self.transient(parent)
            self.grab_set()
            if not _utest:
                self.wait_window()

    def CreateWidgets(self):
        "Create Frame with Text (with vertical Scrollbar) and Button."
        frameText = Frame(self, relief=SUNKEN, height=700)
        frameButtons = Frame(self)
        self.buttonOk = Button(frameButtons, text='Close',
                               command=self.Ok, takefocus=FALSE)
        self.scrollbarView = Scrollbar(frameText, orient=VERTICAL,
                                       takefocus=FALSE)
        self.textView = Text(frameText, wrap=WORD, highlightthickness=0,
                             fg=self.fg, bg=self.bg)
        self.scrollbarView.config(command=self.textView.yview)
        self.textView.config(yscrollcommand=self.scrollbarView.set)
        self.buttonOk.pack()
        self.scrollbarView.pack(side=RIGHT,fill=Y)
        self.textView.pack(side=LEFT,expand=TRUE,fill=BOTH)
        frameButtons.pack(side=BOTTOM,fill=X)
        frameText.pack(side=TOP,expand=TRUE,fill=BOTH)

    def Ok(self, event=None):
        self.destroy()
开发者ID:varunsharma,项目名称:cpython,代码行数:62,代码来源:textview.py

示例3: _addNeueMahlzeitFrame

# 需要导入模块: from tkinter.ttk import Scrollbar [as 别名]
# 或者: from tkinter.ttk.Scrollbar import pack [as 别名]
    def _addNeueMahlzeitFrame(self):
        self.fr_neue_mz = Frame(self.fr_mahlzeit)
        self.fr_neue_mz.grid_rowconfigure(2, weight=1)
        self.fr_neue_mz.grid(row=0, column=1, sticky="WSNE")
        
        lbl_name = Label(self.fr_neue_mz, text="Name:")
        lbl_name.grid(row=0, column=0, sticky="NW")
        
        self.en_name = Entry(self.fr_neue_mz)
        self.en_name.grid(row=0, column=1, columnspan=2, sticky="WNE")
        
        lbl_zutat = Label(self.fr_neue_mz, text="Zutaten:")
        lbl_zutat.grid(row=1, column=0, sticky="NW")
        

        self.lb_zutat = Listbox(self.fr_neue_mz)
        sb_zutat = Scrollbar(self.lb_zutat, orient=VERTICAL)
        self.lb_zutat.configure(yscrollcommand=sb_zutat.set)
        sb_zutat.configure(command=self.lb_zutat.yview)
        sb_zutat.pack(side="right", fill="both")
        self.lb_zutat.grid(row=2, column=0, columnspan=3, sticky="NWSE")
        
        self.var_zutat = StringVar(self.fr_neue_mz)
        
        self.opt_zutat = OptionMenu(self.fr_neue_mz, self.var_zutat, "Auswahl")
        self.opt_zutat.grid(row=3, column=0)
        
        self.en_menge = Entry(self.fr_neue_mz)
        self.en_menge.grid(row=3, column=1)
        
        self.btn_mahlzeit_hinzu = Button(self.fr_neue_mz, text="Hinzu")
        self.btn_mahlzeit_hinzu.grid(row=3, column=2, sticky="E")
开发者ID:karacho84,项目名称:dinnerlog,代码行数:34,代码来源:gui.py

示例4: TextViewer

# 需要导入模块: from tkinter.ttk import Scrollbar [as 别名]
# 或者: from tkinter.ttk.Scrollbar import pack [as 别名]
class TextViewer(Toplevel):
    """A simple text viewer dialog for IDLE

    """
    def __init__(self, parent, title, text, modal=True, _htest=False):
        """Show the given text in a scrollable window with a 'close' button

        If modal option set to False, user can interact with other windows,
        otherwise they will be unable to interact with other windows until
        the textview window is closed.

        _htest - bool; change box location when running htest.
        """
        Toplevel.__init__(self, parent)
        self.configure(borderwidth=5)
        # place dialog below parent if running htest
        self.geometry("=%dx%d+%d+%d" % (750, 500,
                           parent.winfo_rootx() + 10,
                           parent.winfo_rooty() + (10 if not _htest else 100)))
        #elguavas - config placeholders til config stuff completed
        self.bg = '#ffffff'
        self.fg = '#000000'

        self.CreateWidgets()
        self.title(title)
        self.protocol("WM_DELETE_WINDOW", self.Ok)
        self.parent = parent
        self.textView.focus_set()
        #key bindings for this dialog
        self.bind('<Return>',self.Ok) #dismiss dialog
        self.bind('<Escape>',self.Ok) #dismiss dialog
        self.textView.insert(0.0, text)
        self.textView.config(state=DISABLED)

        if modal:
            self.transient(parent)
            self.grab_set()
            self.wait_window()

    def CreateWidgets(self):
        frameText = Frame(self, relief=SUNKEN, height=700)
        frameButtons = Frame(self)
        self.buttonOk = Button(frameButtons, text='Close',
                               command=self.Ok, takefocus=FALSE)
        self.scrollbarView = Scrollbar(frameText, orient=VERTICAL,
                                       takefocus=FALSE)
        self.textView = Text(frameText, wrap=WORD, highlightthickness=0,
                             fg=self.fg, bg=self.bg)
        self.scrollbarView.config(command=self.textView.yview)
        self.textView.config(yscrollcommand=self.scrollbarView.set)
        self.buttonOk.pack()
        self.scrollbarView.pack(side=RIGHT,fill=Y)
        self.textView.pack(side=LEFT,expand=TRUE,fill=BOTH)
        frameButtons.pack(side=BOTTOM,fill=X)
        frameText.pack(side=TOP,expand=TRUE,fill=BOTH)

    def Ok(self, event=None):
        self.destroy()
开发者ID:Niansheng,项目名称:cpython,代码行数:60,代码来源:textview.py

示例5: progress

# 需要导入模块: from tkinter.ttk import Scrollbar [as 别名]
# 或者: from tkinter.ttk.Scrollbar import pack [as 别名]
 def progress( self ):
     o=os.popen("cd {0} && snakemake --dryrun --rerun-incomplete > {0}/Reports/checkpoint".format(self.workpath.get()))
     o.close()
     F=open("{0}/Reports/checkpoint".format(self.workpath.get()),"r").read()
     rules2={}
     rules=re.findall(r'rule .+:',F)
     for i in rules:
         i=re.sub("rule ","",i)
         i=re.sub(":","",i)
         rules2[i]=0
 
 
     F=open("{0}/Reports/{1}.dot".format(self.workpath.get(), self.Pipeline.get() ),"r").read()
     for i in rules2.keys():
         F=re.sub(r'('+i+')(\".+?)\".+?\"',r'\1_pending\2"0.0 0.0 0.0"',F)
 #        F=re.sub(i,"",F)
 
 
     G=open("{0}/Reports/{1}-{2}.dot".format(self.workpath.get(),self.Pipeline.get(),"progress"),"w")
     G.write(F)
     G.close()
 
     o=os.popen("cd {0}/Reports && dot -Tpng -o {0}/Reports/{1}-progress.png {0}/Reports/{1}-progress.dot;convert {0}/Reports/{1}-progress.png {0}/Reports/{1}-progress.gif".format(self.workpath.get(),self.Pipeline.get()))
 
 #    tkinter.messagebox.showerror("o",o)
 
     PL=self.Pipeline.get() #pipelineget()
     gf=Toplevel()
 
     gf.title("CCBR Pipeliner: {0} Progress Graph".format(PL))
     cgf = Canvas(gf,bg="white")
 #    gff=Frame(cgf,width=300,height=300)
     xscrollbar = Scrollbar(gf, orient=HORIZONTAL)
     xscrollbar.pack(side = BOTTOM, fill=X )
     xscrollbar.config(command=cgf.xview)
 
     yscrollbar = Scrollbar(gf,orient=VERTICAL)
     yscrollbar.pack(side = RIGHT, fill=Y )
     yscrollbar.config(command=cgf.yview)
 
     cgf.config(xscrollcommand=xscrollbar.set, yscrollcommand=yscrollbar.set)
     cgf.config(width=600,height=600)
     cgf.pack(expand=1,fill=BOTH,side=RIGHT)
     cgf.config(scrollregion=(0,0,1000,5000))
     try:
         time.sleep(5)
         img = PhotoImage(file="{0}/Reports/{1}-progress.gif".format(self.workpath.get(),PL))
     except:
         time.sleep(5)
         img = PhotoImage(file="{0}/Reports/{1}-progress.gif".format(self.workpath.get(),PL))
     cgf.create_image(0,0,image=img, anchor="nw")
     cgf.image=img
开发者ID:felloumi,项目名称:Pipeliner,代码行数:54,代码来源:frame.py

示例6: Table

# 需要导入模块: from tkinter.ttk import Scrollbar [as 别名]
# 或者: from tkinter.ttk.Scrollbar import pack [as 别名]
class Table(Frame):
    def __init__(self, parent, title, columns):
        Frame.__init__(self, parent)
        self.pack(expand=YES, fill=BOTH)

        self.title_lbl = Label(self, text=title, font=GENERAL_FONT)
        self.table_tree = Treeview(self, columns=columns)

        # добавить Scrollbar
        self.scroll = Scroll(self, orient=VERTICAL, command=self.table_tree.yview)
        self.table_tree['yscroll'] = self.scroll.set

        for i in range(len(columns)):
            self.table_tree.heading(columns[i], text=columns[i])

        self.place_widgets()

    def place_widgets(self):
        self.title_lbl.pack(side=TOP, fill=X, expand=YES)
        self.table_tree.pack(side=LEFT, fill=BOTH, expand=YES)
        self.scroll.pack(side=RIGHT, fill=Y, expand=YES)
开发者ID:fargelus,项目名称:SAPR,代码行数:23,代码来源:generaltable.py

示例7: __init__

# 需要导入模块: from tkinter.ttk import Scrollbar [as 别名]
# 或者: from tkinter.ttk.Scrollbar import pack [as 别名]
        def __init__(self, parent, *args, **kw):
            Frame.__init__(self, parent, *args, **kw)

            # create a canvas object and a vertical scrollbar for scrolling it
            vscrollbar = Scrollbar(self, orient=VERTICAL)
            vscrollbar.pack(fill=Y, side=RIGHT, expand=False)
            self.canvas = canvas = StyledCanvas(
                self, bd=0, highlightthickness=0,
                yscrollcommand=vscrollbar.set)
            canvas.pack(side=LEFT, fill=BOTH, expand=True)
            vscrollbar.config(command=canvas.yview)

            # reset the view
            canvas.xview_moveto(0)
            canvas.yview_moveto(0)

            # create a frame inside the canvas which will be scrolled with it
            self.interior = interior = Frame(canvas)
            interior_id = canvas.create_window(0, 0, window=interior,
                                               anchor=N+W)

            # track changes to the canvas and frame width and sync them,
            # also updating the scrollbar
            def _configure_interior(event):
                # update the scrollbars to match the size of the inner frame
                size = (interior.winfo_reqwidth(), interior.winfo_reqheight())
                canvas.config(scrollregion="0 0 %s %s" % size)
                if interior.winfo_reqwidth() != canvas.winfo_width():
                    # update the canvas's width to fit the inner frame
                    canvas.config(width=interior.winfo_reqwidth())
            interior.bind('<Configure>', _configure_interior)

            def _configure_canvas(event):
                if interior.winfo_reqwidth() != canvas.winfo_width():
                   # update the inner frame's width to fill the canvas
                    canvas.itemconfigure(interior_id,
                                         width=canvas.winfo_width())
            canvas.bind('<Configure>', _configure_canvas)
            MouseWheel(self).add_scrolling(canvas, yscrollbar=vscrollbar)
开发者ID:nishimaomaoxiong,项目名称:pyDEA,代码行数:41,代码来源:scrollable_frame_gui.py

示例8: workflow

# 需要导入模块: from tkinter.ttk import Scrollbar [as 别名]
# 或者: from tkinter.ttk.Scrollbar import pack [as 别名]
    def workflow(self):
        PL=self.Pipeline.get() #pipelineget()
        gf=Toplevel()
        #MkaS=os.popen("./makeasnake.py 2>&1 | tee -a "+workpath.get()+"/Reports/makeasnake.log").read()
    
        gf.title("CCBR Pipeliner: "+ PL + " Workflow Graph")
        cgf = Canvas(gf,bg="white")
        #gff=Frame(cgf,width=300,height=300)
        xscrollbar = Scrollbar(gf, orient=HORIZONTAL)
        xscrollbar.pack(side = BOTTOM, fill=X )
        xscrollbar.config(command=cgf.xview)

        yscrollbar = Scrollbar(gf,orient=VERTICAL)
        yscrollbar.pack(side = RIGHT, fill=Y )
        yscrollbar.config(command=cgf.yview)

        cgf.config(xscrollcommand=xscrollbar.set, yscrollcommand=yscrollbar.set)
        cgf.config(width=600,height=600)
        cgf.pack(expand=1,fill=BOTH,side=RIGHT)
        cgf.config(scrollregion=(0,0,5000,20000))
        img = PhotoImage(file=self.workpath.get()+"/Reports/"+PL+".gif")
        cgf.create_image(0,0,image=img, anchor="nw")
        cgf.image=img
开发者ID:felloumi,项目名称:Pipeliner,代码行数:25,代码来源:frame.py

示例9: __init__

# 需要导入模块: from tkinter.ttk import Scrollbar [as 别名]
# 或者: from tkinter.ttk.Scrollbar import pack [as 别名]
    def __init__(self):
        '''
        Constructor
        '''
        self.root = Tk()
        
        self.root.title("DinnerLog")
        self.root.minsize(800, 600)
        self.root.grid_columnconfigure(0, weight=1)
        self.root.grid_rowconfigure(0, weight=1)
        self.root.grid_rowconfigure(1, weight=3)
        
        # Ein Frame für alles, das mit Zutaten zu tun hat
        self.fr_zutaten = Labelframe(self.root, borderwidth=2, relief=GROOVE, text="Zutaten")
        self.fr_zutaten.grid_columnconfigure(0, weight=1)
        self.fr_zutaten.grid_rowconfigure(0, weight=1)
        self.fr_zutaten.grid(row=0, column=0, sticky="NSWE")
        

        self.lb_zutaten = Listbox(self.fr_zutaten)
        sb_zutaten = Scrollbar(self.lb_zutaten, orient=VERTICAL)
        self.lb_zutaten.configure(yscrollcommand=sb_zutaten.set)
        sb_zutaten.config(command=self.lb_zutaten.yview)
        sb_zutaten.pack(side="right", fill="both")
        self.lb_zutaten.grid(row=0, column=0, sticky="NSEW")
        
        self._addNeueZutatFrame()    

        # Ein Frame in den alles, das mit Mahlzeiten zu tun hat, kommt
        self.fr_mahlzeit = Labelframe(self.root, borderwidth=2, relief=GROOVE, text="Mahlzeiten")
        self.fr_mahlzeit.grid_columnconfigure(0, weight=1)
        self.fr_mahlzeit.grid_rowconfigure(0, weight=1)
        self.fr_mahlzeit.grid(row=1, column=0, sticky="NSWE")
        
        self._addNeueMahlzeitFrame()
        

        self.lb_mahlzeiten = Listbox(self.fr_mahlzeit, selectmode=SINGLE)
        sb_mahlzeiten = Scrollbar(self.lb_mahlzeiten, orient=VERTICAL)
        sb_mahlzeiten.configure(command=self.lb_mahlzeiten.yview)
        self.lb_mahlzeiten.configure(yscrollcommand=sb_mahlzeiten.set)
        sb_mahlzeiten.pack(side="right", fill="both")
        self.lb_mahlzeiten.grid(row=0, column=0, sticky="NSEW")
        
        fr_neu_ok = Frame(self.fr_mahlzeit)
        fr_neu_ok.grid(row=1, column=0, columnspan=2, sticky="E")
    
        self.btn_neu = Button(fr_neu_ok, text="Neu")
        self.btn_neu.pack(side="left")
        
        self.btn_mahlzeit_als_zt = Button(fr_neu_ok, text="Als Zutat")
        self.btn_mahlzeit_als_zt.pack(anchor=E, side="right")
        
        self.btn_insert = Button(fr_neu_ok, text="Hinzufuegen")
        self.btn_insert.pack(anchor=E, side="right")
        
        self.btn_update = Button(fr_neu_ok, text="Update")
        self.btn_update.pack(anchor=E, side="right")
        
        self.btn_delete = Button(fr_neu_ok, text="Loeschen")
        self.btn_delete.pack(anchor=E, side="right")
        
        # Ein Frame der Statistiken darstellt
        self.fr_stats = Labelframe(self.root, borderwidth=2, relief=GROOVE, text="Statistik")
        self.fr_stats.grid(row=3, column=0, sticky="NSWE")
开发者ID:karacho84,项目名称:dinnerlog,代码行数:67,代码来源:gui.py

示例10: run

# 需要导入模块: from tkinter.ttk import Scrollbar [as 别名]
# 或者: from tkinter.ttk.Scrollbar import pack [as 别名]
def run(*tests):
    root = tk.Tk()
    root.title('IDLE htest')
    root.resizable(0, 0)

    # a scrollable Label like constant width text widget.
    frameLabel = tk.Frame(root, padx=10)
    frameLabel.pack()
    text = tk.Text(frameLabel, wrap='word')
    text.configure(bg=root.cget('bg'), relief='flat', height=4, width=70)
    scrollbar = Scrollbar(frameLabel, command=text.yview)
    text.config(yscrollcommand=scrollbar.set)
    scrollbar.pack(side='right', fill='y', expand=False)
    text.pack(side='left', fill='both', expand=True)

    test_list = [] # List of tuples of the form (spec, callable widget)
    if tests:
        for test in tests:
            test_spec = globals()[test.__name__ + '_spec']
            test_spec['name'] = test.__name__
            test_list.append((test_spec,  test))
    else:
        for k, d in globals().items():
            if k.endswith('_spec'):
                test_name = k[:-5]
                test_spec = d
                test_spec['name'] = test_name
                mod = import_module('idlelib.' + test_spec['file'])
                test = getattr(mod, test_name)
                test_list.append((test_spec, test))

    test_name = tk.StringVar(root)
    callable_object = None
    test_kwds = None

    def next():

        nonlocal test_name, callable_object, test_kwds
        if len(test_list) == 1:
            next_button.pack_forget()
        test_spec, callable_object = test_list.pop()
        test_kwds = test_spec['kwds']
        test_kwds['parent'] = root
        test_name.set('Test ' + test_spec['name'])

        text.configure(state='normal') # enable text editing
        text.delete('1.0','end')
        text.insert("1.0",test_spec['msg'])
        text.configure(state='disabled') # preserve read-only property

    def run_test():
        widget = callable_object(**test_kwds)
        try:
            print(widget.result)
        except AttributeError:
            pass

    button = tk.Button(root, textvariable=test_name, command=run_test)
    button.pack()
    next_button = tk.Button(root, text="Next", command=next)
    next_button.pack()

    next()

    root.mainloop()
开发者ID:hoonkim,项目名称:cpython,代码行数:67,代码来源:htest.py

示例11: BibleReferenceBox

# 需要导入模块: from tkinter.ttk import Scrollbar [as 别名]
# 或者: from tkinter.ttk.Scrollbar import pack [as 别名]
class BibleReferenceBox( Frame, BibleBoxAddon ):
    """
    """
    def __init__( self, parentWindow, parentFrame, parentApp, internalBible, referenceObject ):
        """
        """
        if BibleOrgSysGlobals.debugFlag: print( exp("BibleReferenceBox.__init__( {}, {}. {}, {}, {} )").format( parentWindow, parentFrame, parentApp, internalBible.getAName(), referenceObject ) )
        self.parentWindow, self.parentFrame, self.parentApp, self.referenceObject = parentWindow, parentFrame, parentApp, referenceObject
        self.internalBible = handleInternalBibles( self.parentApp, internalBible, self )

        Frame.__init__( self, parentFrame )
        BibleBoxAddon.__init__( self, parentWindow, 'BibleReferenceBox' )

        # Set some dummy values required soon
        #self._contextViewRadioVar, self._formatViewRadioVar, self._groupRadioVar = tk.IntVar(), tk.IntVar(), tk.StringVar()
        #self._groupCode = BIBLE_GROUP_CODES[0] # Put into first/default BCV group
        #self._contextViewMode = DEFAULT
        #self._formatViewMode = DEFAULT
        self.currentVerseKey = SimpleVerseKey( 'UNK','1','1' ) # Unknown book

        #if self._contextViewMode == DEFAULT:
            #self._contextViewMode = 'ByVerse'
            #self.parentWindow.viewVersesBefore, self.parentWindow.viewVersesAfter = 2, 6
        #if self._formatViewMode == DEFAULT:
            #self._formatViewMode = 'Formatted'

        # Create a title bar
        titleBar = Frame( self )
        Button( titleBar, text=_('Close'), command=self.doClose ).pack( side=tk.RIGHT )
        ## Try to get the title width somewhere near correct (if moduleID is a long path)
        #adjModuleID = moduleID
        #self.update() # so we can get the geometry
        #width = parseWindowSize( self.parentWindow.winfo_geometry() )[0] - 60 # Allow for above button
        #if len(adjModuleID)*10 > width: # Note: this doesn't adjust if the window size is changed
            #print( "BRB here1", len(adjModuleID), width, repr(adjModuleID) )
            #x = len(adjModuleID)*100/width # not perfect (too small) for narrow windows
            #adjModuleID = '…' + adjModuleID[int(x):]
            #print( "BRB here2", len(adjModuleID), x, repr(adjModuleID) )
        #titleText = '{} ({})'.format( adjModuleID, boxType.replace( 'BibleReferenceBox', '' ) )
        titleText = self.referenceObject.getShortText()
        self.titleLabel = tk.Label( titleBar, text=titleText )
        self.titleLabel.pack( side=tk.TOP, fill=tk.X )
        titleBar.pack( side=tk.TOP, fill=tk.X )

        # Create a scroll bar to fill the right-hand side of the window
        self.vScrollbar = Scrollbar( self )
        self.vScrollbar.pack( side=tk.RIGHT, fill=tk.Y )

        self.textBox = BText( self, height=5, yscrollcommand=self.vScrollbar.set )
        self.textBox.configure( wrap='word' )
        self.textBox.pack( expand=tk.YES, fill=tk.X ) # Full width
        self.vScrollbar.configure( command=self.textBox.yview ) # link the scrollbar to the text box
        self.createStandardBoxKeyboardBindings()
        self.textBox.bind( '<Button-1>', self.setFocus ) # So disabled text box can still do select and copy functions

        # Set-up our standard Bible styles
        for USFMKey, styleDict in self.parentApp.stylesheet.getTKStyles().items():
            self.textBox.tag_configure( USFMKey, **styleDict ) # Create the style
        # Add our extra specialised styles
        self.textBox.tag_configure( 'contextHeader', background='pink', font='helvetica 6 bold' )
        self.textBox.tag_configure( 'context', background='pink', font='helvetica 6' )
        self.textBox.tag_configure( 'markersHeader', background='yellow3', font='helvetica 6 bold' )
        self.textBox.tag_configure( 'markers', background='yellow3', font='helvetica 6' )

        self.pack( expand=tk.YES, fill=tk.BOTH ) # Pack the frame

        # Set-up our Bible system and our callables
        self.BibleOrganisationalSystem = BibleOrganizationalSystem( 'GENERIC-KJV-80-ENG' ) # temp
        self.getNumChapters = self.BibleOrganisationalSystem.getNumChapters
        self.getNumVerses = lambda BBB,C: MAX_PSEUDOVERSES if C=='-1' or C==-1 \
                                        else self.BibleOrganisationalSystem.getNumVerses( BBB, C )
        self.isValidBCVRef = self.BibleOrganisationalSystem.isValidBCVRef
        self.getFirstBookCode = self.BibleOrganisationalSystem.getFirstBookCode
        self.getPreviousBookCode = self.BibleOrganisationalSystem.getPreviousBookCode
        self.getNextBookCode = self.BibleOrganisationalSystem.getNextBookCode
        self.getBBBFromText = self.BibleOrganisationalSystem.getBBBFromText
        self.getBookName = self.BibleOrganisationalSystem.getBookName
        self.getBookList = self.BibleOrganisationalSystem.getBookList
        self.maxChaptersThisBook, self.maxVersesThisChapter = 150, 150 # temp

        self.verseCache = OrderedDict()

        self.updateShownReferences( self.referenceObject )
    # end of BibleReferenceBox.__init__


    def createStandardBoxKeyboardBindings( self ):
        """
        Create keyboard bindings for this widget.
        """
        if BibleOrgSysGlobals.debugFlag and debuggingThisModule:
            print( exp("BibleReferenceBox.createStandardBoxKeyboardBindings()") )
        for name,command in ( ('SelectAll',self.doSelectAll), ('Copy',self.doCopy),
                             ('Find',self.doBoxFind), ('Refind',self.doBoxRefind),
                             #('Info',self.doShowInfo),
                             #('ShowMain',self.doShowMainWindow),
                             ('Close',self.doClose),
                             ):
            self._createStandardBoxKeyboardBinding( name, command )
    # end of BibleReferenceBox.createStandardBoxKeyboardBindings()
#.........这里部分代码省略.........
开发者ID:openscriptures,项目名称:Biblelator,代码行数:103,代码来源:BibleReferenceCollection.py

示例12: BibleReferenceCollectionWindow

# 需要导入模块: from tkinter.ttk import Scrollbar [as 别名]
# 或者: from tkinter.ttk.Scrollbar import pack [as 别名]
class BibleReferenceCollectionWindow( ChildWindow, BibleResourceWindowAddon ):
    """
    """
    def __init__( self, parentApp, internalBible, defaultContextViewMode=BIBLE_CONTEXT_VIEW_MODES[0], defaultFormatViewMode=BIBLE_FORMAT_VIEW_MODES[0] ):
        """
        Given a collection name, try to open an empty Bible resource collection window.
        """
        if BibleOrgSysGlobals.debugFlag:
            print( "BibleReferenceCollectionWindow.__init__( {}, {} )".format( parentApp, internalBible.getAName() ) )
        self.internalBible = internalBible
        ChildWindow.__init__( self, parentApp, genericWindowType='BibleResource' )
        BibleResourceWindowAddon.__init__( self, 'BibleReferenceCollectionWindow', internalBible.getAName(), defaultContextViewMode, defaultFormatViewMode )

        self.geometry( INITIAL_REFERENCE_COLLECTION_SIZE )
        self.minimumSize, self.maximumSize = MINIMUM_REFERENCE_COLLECTION_SIZE, MAXIMUM_REFERENCE_COLLECTION_SIZE
        self.minsize( *parseWindowSize( self.minimumSize ) )
        self.maxsize( *parseWindowSize( self.maximumSize ) )

        # Get rid of the default widgets
        self.vScrollbar.destroy()
        self.textBox.destroy()

        # Make a frame inside a canvas inside our window (in order to get a scrollbar)
        self.canvas = tk.Canvas( self, borderwidth=0, background='pink' ) #background="#ffffff" )
        self.vsb = Scrollbar( self, orient='vertical', command=self.canvas.yview )
        self.canvas.configure( yscrollcommand=self.vsb.set )
        self.vsb.pack( side=tk.RIGHT, fill=tk.Y )
        self.canvas.pack( side=tk.LEFT, expand=tk.YES, fill=tk.BOTH )
        self.canvasFrame = Frame( self.canvas ) #, background="#ffffff" )
        #self.canvasFrame.columnconfigure( 0, weight=1 )
        #self.canvasFrame.rowconfigure( 0, weight=1 )
        self.window = self.canvas.create_window( (0,0), window=self.canvasFrame, anchor='nw', tags='self.canvasFrame' )
        #self.columnconfigure( 0, weight=1 )
        #self.rowconfigure( 0, weight=1 )
        #self.canvasFrame.bind( '<Configure>', self.OnFrameConfigure )
        self.canvas.bind('<Configure>', self.onCanvasConfigure )

        #self.BCVUpdateType = 'ReferencesMode' # Leave as default
        self.folderPath = self.filename = self.filepath = None
        self.referenceBoxes = BibleReferenceBoxes( self )

        if BibleOrgSysGlobals.debugFlag and debuggingThisModule:
            print( exp("BibleReferenceCollectionWindow.__init__ finished.") )
    # end of BibleReferenceCollectionWindow.__init__

    def onCanvasConfigure( self, event ):
        """
        """
        if BibleOrgSysGlobals.debugFlag and debuggingThisModule:
            print( exp("BibleReferenceCollectionWindow.onCanvasConfigure( {} )").format( event ) )

        canvas_width = event.width
        #print( "  Set canvas width to {}".format( canvas_width ) )

        self.canvas.itemconfigure( self.window, width=event.width)
        self.canvas.configure( scrollregion=self.canvas.bbox( 'all' ) )
        #self.canvas.itemconfigure( self.canvasFrame, width=canvas_width )
    # end of BibleReferenceCollectionWindow.onCanvasConfigure

    #def OnFrameConfigure( self, event ):
        #"""
        #Reset the scroll region to encompass the inner frame.
        #"""
        #if BibleOrgSysGlobals.debugFlag and debuggingThisModule:
            #print( exp("BibleReferenceCollectionWindow.OnFrameConfigure( {} )").format( event ) )

        #self.canvas.configure( scrollregion=self.canvas.bbox( 'all' ) )
    ## end of BibleReferenceCollectionWindow.OnFrameConfigure


    def setFolderPath( self, newFolderPath ):
        """
        Store the folder path for where our internal Bible files will be.

        We're still waiting for the filename.
        """
        if BibleOrgSysGlobals.debugFlag and debuggingThisModule:
            print( exp("BibleReferenceCollectionWindow.setFolderPath( {!r} )").format( newFolderPath ) )
            assert self.filename is None
            assert self.filepath is None

        self.folderPath = newFolderPath
    # end of BibleReferenceCollectionWindow.setFolderPath


    def createMenuBar( self ):
        """
        """
        if BibleOrgSysGlobals.debugFlag and debuggingThisModule:
            print( exp("BibleReferenceCollectionWindow.createMenuBar()") )

        self.menubar = tk.Menu( self )
        #self['menu'] = self.menubar
        self.configure( menu=self.menubar ) # alternative

        fileMenu = tk.Menu( self.menubar, tearoff=False )
        self.menubar.add_cascade( menu=fileMenu, label=_('File'), underline=0 )
        #fileMenu.add_command( label=_('Info…'), underline=0, command=self.doShowInfo, accelerator=self.parentApp.keyBindingDict[_('Info')][0] )
        #fileMenu.add_separator()
        #fileMenu.add_command( label=_('Rename'), underline=0, command=self.doRename )
#.........这里部分代码省略.........
开发者ID:openscriptures,项目名称:Biblelator,代码行数:103,代码来源:BibleReferenceCollection.py

示例13: CimFilePage

# 需要导入模块: from tkinter.ttk import Scrollbar [as 别名]
# 或者: from tkinter.ttk.Scrollbar import pack [as 别名]
class CimFilePage(Notebook):
    def __init__(self, parent):
        Notebook.__init__(self, parent, style='Type.TNotebook')
        logger = logging.getLogger(__name__)

        s = Style()
        s.configure('Type.TNotebook', tabposition="se")
        
        self.page_tiborcim = Frame(self)
        self.page_python = Frame(self)
        self.add(self.page_tiborcim, text='Tiborcim')
        self.add(self.page_python, text='Python')

        self.text_tiborcim = CimTiborcimText(self.page_tiborcim, self)

        self.vbar_python = Scrollbar(self.page_python, name='vbar_python')
        self.xbar_python = Scrollbar(self.page_python, name='xbar_python', orient="horizontal")
        self.text_python = Text(self.page_python, wrap="none", state="disabled", borderwidth='0p')
        self.vbar_python['command'] = self.text_python.yview
        self.vbar_python.pack(side="right", fill="y")
        self.text_python['yscrollcommand'] = self.vbar_python.set
        self.xbar_python['command'] = self.text_python.xview
        self.xbar_python.pack(side="bottom", fill="x")
        self.text_python['xscrollcommand'] = self.xbar_python.set
        self.text_python.pack(expand=1, fill="both")

        self.viewmode = "tiborcim"
        self.saved = True
        self.filename = None

    def save_file(self):
        if self.filename is None:
            self.save_file_as()
        else:
            self.saved = True;
            self.text_tiborcim.edit_modified(False)
            f = open(self.filename, "w")
            f.write(self.text_tiborcim.get("1.0", "end"))
            f.close() 

    def convert_file(self):
        from tiborcim.tibc import compiler as tibc
        # Should warn if unsaved...
        com = tibc(self.text_tiborcim.get("1.0", "end"))
        try:
            self.text_python.config(state="normal")
            self.text_python.delete("1.0", "end")
            self.text_python.insert("end", ''.join(com.output))
            self.text_python.config(state="disabled")
        except:
            logging.warning("That's Odd")

    def save_file_as(self):
        f = asksaveasfile(mode='w', defaultextension=".tibas", filetypes=(("Tiborcim", "*.tibas"),("All files", "*.*") ))
        if f is not None:
            self.filename = f.name
            self.save_file()
        
    def load_file(self, name):
        self.filename = name
        logging.debug('Load ' + name)
        try:
            f = open(name)
            self.text_tiborcim.delete("1.0")
            self.text_tiborcim.insert("1.0", f.read())
            self.text_tiborcim.delete('end - 1 chars')
            self.saved = True;
            f.close()
        except:
            showerror("Open Source File", "Failed to read file\n'%s'" % name)
        return

    def view_tiborcim(self, event=None):
        self.select(self.page_tiborcim)
        self.viewmode = "tiborcim"

    def view_python(self, event=None):
        self.select(self.page_python)
        self.viewmode = "python"

    def get_file(self):
        filebit = self.filename.split(sep)
        if len(filebit) == 1:
            filebit = self.filename.split(altsep)
        return filebit[len(filebit) - 1];

    def close(self):
        if not self.saved:
            if askokcancel("Unsaved Changes", "Somefiles havent been saved!"):
                logging.debug("Close Anyway")
                return True
            else:
                self.save_file()
                return False
        else:
            return True
开发者ID:ZanderBrown,项目名称:Tiborcim,代码行数:98,代码来源:cim.py

示例14: __init__

# 需要导入模块: from tkinter.ttk import Scrollbar [as 别名]
# 或者: from tkinter.ttk.Scrollbar import pack [as 别名]
    def __init__(self):
        Tk.__init__(self)
        self.wm_title("BioInfo : comparaison des listes")
        self.resizable(width=FALSE, height=FALSE)
        self.SortDir = False

        # Lists Types
        self.typeList1 = None
        self.typeList2 = None

        # Frame content
        self.frameContent = Frame(self)
        self.frameContent.pack(side=TOP, fill=X)

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

        # Result Content
        self.dataCols = ('microArn_A', 'microArn_B', 'FoldC', 'p-Value', 'Note')
        self.tree = Treeview(self.frameContent, columns=self.dataCols, show = 'headings', yscrollcommand=scrollbar.set)

        # configure column headings
        for c in self.dataCols:
            self.tree.heading(c, text=c, command=lambda c=c: self.columnSort(c, self.SortDir))
            self.tree.column(c, width=10)

        self.tree.pack(side=LEFT, fill=X, expand="yes")

        scrollbar.config(command=self.tree.yview)

        # Frame Lists
        self.frameLists = Frame(self)
        self.frameLists.pack(side=LEFT)

        # Frame Forms
        self.frameForms = Frame(self)
        self.frameForms.pack(side=LEFT, padx=20)

        #Liste n°1 selection
        self.frameList1 = Frame(self.frameLists)
        self.frameList1.pack()

        self.typeListStr1 = StringVar(self.frameList1)
        self.typeListStr1.set(str(ListBioType.TypeA))

        self.buttonTypeList1 = OptionMenu(self.frameList1, self.typeListStr1, str(ListBioType.TypeA), str(ListBioType.TypeB)).pack(side=LEFT)

        self.entrylist1 = Entry(self.frameList1, width=30)
        self.entrylist1.pack(side=LEFT)

        self.buttonBrowseList1 = Button(self.frameList1, text="Parcourir", command=self.load_fileList1, width=10)
        self.buttonBrowseList1.pack(side=LEFT, padx=5)

        # List n°2 selection
        self.frameList2 = Frame(self.frameLists)
        self.frameList2.pack(side=BOTTOM)

        self.typeListStr2 = StringVar(self.frameList2)
        self.typeListStr2.set(str(ListBioType.TypeB))

        self.buttonTypeList2 = OptionMenu(self.frameList2, self.typeListStr2, str(ListBioType.TypeA), str(ListBioType.TypeB)).pack(side=LEFT)

        self.entrylist2 = Entry(self.frameList2, width=30)
        self.entrylist2.pack(side=LEFT)

        self.buttonBrowseList2 = Button(self.frameList2, text="Parcourir", command=self.load_fileList2, width=10)
        self.buttonBrowseList2.pack(side=LEFT, padx=5)

        # Form pValue
        self.framePVal = Frame(self.frameForms)
        self.framePVal.pack()

        Label(self.framePVal, text="pValue").pack(side=LEFT)
        self.entryPVal = Entry(self.framePVal, width=6)
        self.entryPVal.pack(side=LEFT)

        # Form foldC
        self.frameFoldC = Frame(self.frameForms)
        self.frameFoldC.pack()

        Label(self.frameFoldC, text="foldCh").pack(side=LEFT)
        self.entryFoldC = Entry(self.frameFoldC, width=6)
        self.entryFoldC.pack(side=LEFT)

        # Form note
        self.frameNote = Frame(self.frameForms)
        self.frameNote.pack()

        Label(self.frameNote, text="note    ").pack(side=LEFT)
        self.entryNote = Entry(self.frameNote, width=6)
        self.entryNote.pack(side=LEFT)

        # Bouton comparer
        self.buttonComparer = Button(self, text="Comparer", command=self.compare, width=10, state=DISABLED)
        self.buttonComparer.pack(fill= X, expand="yes", padx=20, pady=(10,0))

        #Bouton exporter
        self.buttonExport = Button(self, text="Exporter", command=self.export, width=10, state=DISABLED)
        self.buttonExport.pack(fill= X, expand="yes", padx=20)
#.........这里部分代码省略.........
开发者ID:S0obi,项目名称:BioInfo,代码行数:103,代码来源:BioInfo.py

示例15: ChildWindow

# 需要导入模块: from tkinter.ttk import Scrollbar [as 别名]
# 或者: from tkinter.ttk.Scrollbar import pack [as 别名]
class ChildWindow( tk.Toplevel, ChildBox ):
    """
    """
    def __init__( self, parentApp, genericWindowType ):
        """
        The genericWindowType is set here,
            but the more specific winType is set later by the subclass.
        """
        if BibleOrgSysGlobals.debugFlag and debuggingThisModule:
            print( exp("ChildWindow.__init__( {} {} )").format( parentApp, repr(genericWindowType) ) )
            assert( parentApp )
            assert( genericWindowType in ('BibleResource','LexiconResource','TextEditor','BibleEditor',) )
        self.parentApp, self.genericWindowType = parentApp, genericWindowType
        tk.Toplevel.__init__( self, self.parentApp )
        ChildBox.__init__( self, self.parentApp )
        self.protocol( "WM_DELETE_WINDOW", self.closeChildWindow )

        self.geometry( INITIAL_RESOURCE_SIZE )
        self.minimumSize, self.maximumSize = MINIMUM_RESOURCE_SIZE, MAXIMUM_RESOURCE_SIZE
        self.minsize( *parseWindowSize( self.minimumSize ) )
        self.maxsize( *parseWindowSize( self.maximumSize ) )

        self.createMenuBar()
        self.createToolBar()
        self.createContextMenu()

        self.viewMode = DEFAULT
        self.settings = None

        # Create a scroll bar to fill the right-hand side of the window
        self.vScrollbar = Scrollbar( self )
        self.vScrollbar.pack( side=tk.RIGHT, fill=tk.Y )

        #if 'textBox' in dir(self): # we have one already -- presumably a specialised one
            #halt # We have one already
        #else: # let's make one

        self.textBox = tk.Text( self, yscrollcommand=self.vScrollbar.set, state=tk.DISABLED )
        self.textBox['wrap'] = 'word'
        self.textBox.pack( expand=tk.YES, fill=tk.BOTH )
        self.vScrollbar.config( command=self.textBox.yview ) # link the scrollbar to the text box
        self.createStandardKeyboardBindings()
        self.textBox.bind( "<Button-1>", self.setFocus ) # So disabled text box can still do select and copy functions

        # Options for find, etc.
        self.optionsDict = {}
        self.optionsDict['caseinsens'] = True

        self.refreshTitle() # Must be in superclass
    # end of ChildWindow.__init__


    def notWrittenYet( self ):
        errorBeep()
        showerror( self, _("Not implemented"), _("Not yet available, sorry") )
    # end of ChildWindow.notWrittenYet


    def createMenuBar( self ):
        logging.critical( exp("PROGRAMMING ERROR: This 'createMenuBar' method MUST be overridden!") )
        if BibleOrgSysGlobals.debugFlag:
            print( exp("This 'createMenuBar' method MUST be overridden!") )
            halt


    def createContextMenu( self ):
        """
        Can be overriden if necessary.
        """
        self.contextMenu = tk.Menu( self, tearoff=0 )
        self.contextMenu.add_command( label="Copy", underline=0, command=self.doCopy, accelerator=self.parentApp.keyBindingDict['Copy'][0] )
        self.contextMenu.add_separator()
        self.contextMenu.add_command( label="Select all", underline=7, command=self.doSelectAll, accelerator=self.parentApp.keyBindingDict['SelectAll'][0] )
        self.contextMenu.add_separator()
        self.contextMenu.add_command( label="Find...", underline=0, command=self.doFind, accelerator=self.parentApp.keyBindingDict['Find'][0] )
        self.contextMenu.add_separator()
        self.contextMenu.add_command( label="Close", underline=1, command=self.doClose, accelerator=self.parentApp.keyBindingDict['Close'][0] )

        self.bind( "<Button-3>", self.showContextMenu ) # right-click
        #self.pack()
    # end of ChildWindow.createContextMenu


    def showContextMenu( self, event ):
        self.contextMenu.post( event.x_root, event.y_root )
    # end of ChildWindow.showContextMenu


    def createToolBar( self ):
        """
        Designed to be overridden.
        """
        #if BibleOrgSysGlobals.debugFlag and debuggingThisModule:
            #print( exp("This 'createToolBar' method can be overridden!") )
        pass
    # end of ChildWindow.createToolBar


    def doHelp( self, event=None ):
        """
#.........这里部分代码省略.........
开发者ID:alerque,项目名称:Biblelator,代码行数:103,代码来源:ChildWindows.py


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