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


Python infrastructure.DemoWindow类代码示例

本文整理汇总了Python中infrastructure.DemoWindow的典型用法代码示例。如果您正苦于以下问题:Python DemoWindow类的具体用法?Python DemoWindow怎么用?Python DemoWindow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __init__

    def __init__(self):
        l="""The listbox below contains a collection of well-known sayings.
        You can scan the list using either of the scrollbars or by dragging
        in the listbox window with button 2 pressed.
        """
            
        DemoWindow.__init__(self, l, 'sayings.py' )

        # create the list
        frame = Frame(self); frame.pack(expand=YES, fill=Y)
        list = Listbox(frame,  setgrid=1)
        vbar = Scrollbar(frame,command=list.yview)
        list['yscrollcommand'] = vbar.set
        hbar = Scrollbar(frame,command=list.xview,orient='horizontal')
        list['xscrollcommand'] = hbar.set

        #pack all toghether
        frame.rowconfigure(0, weight=1)
        frame.columnconfigure(0,weight=1)
        list.grid(row=0,column=0,sticky='nsew')
        vbar.grid(row=0,column=1,sticky='ns')
        hbar.grid(row=1,column=0,sticky='ew')
        

        # fill the list
        for i in sayings:
            list.insert(END,i)
开发者ID:B-Rich,项目名称:widget-tour-py3,代码行数:27,代码来源:sayings.py

示例2: __init__

    def __init__( self ):
        l="""
        Choose the icon and type option of the message box.
        Then press the \"Message Box\" button to see the message box.
        """
        DemoWindow.__init__(self,l,demo_path('msgbox.py'))

        frame=Frame(self);frame.pack(expand=Y, fill=BOTH)

        #create the two option panels
        middleframe=Frame(frame); middleframe.pack(side=TOP,fill=X)
        p1 = OptionPanel(middleframe,'Icon',
                         'error', 'window', 'question', 'warning')
        p1.set('error')
        p1.pack(side=LEFT, expand=YES, fill=BOTH, padx=10, pady=10)
        p2 = OptionPanel(middleframe,'Type',
                         'abortretryignore', 'ok', 'okcancel',
                         'retrycancel', 'yesno' )
        p2.set('ok')
        p2.pack(side=RIGHT, expand=YES, fill=BOTH, padx=10,pady=10)

        b = Button(frame,text='Open Dialog', command=self.opendialog_callback )
        b.pack(side=TOP,fill=X, padx=10)
        
        self.p1, self.p2 = p1,p2 # needed by the callback
开发者ID:B-Rich,项目名称:widget-tour-py3,代码行数:25,代码来源:msgbox.py

示例3: __init__

    def __init__(self):
        l="""Enter a file name in the entry box or click on the
        \"Browse\" buttons to select a file name using the file
        selection dialog."""

        DemoWindow.__init__(self, l, demo_path('filebox.py') )

        frame = Frame(self); frame.pack(side=TOP,expand=YES,fill=BOTH)

        l1 = Label(frame, text='Select a file to open:')
        l2 = Label(frame, text='Select a file to save:')
        e1=Entry(frame); self.e1=e1
        e2=Entry(frame); self.e2=e2
        b1 = Button(frame, text='Browse...', command=self.selectopen_callback)
        b2 = Button(frame, text='Browse...', command=self.selectsave_callback)

        frame.rowconfigure(1,pad=10, weight=1)
        for r in (0,1,2):
            frame.columnconfigure(r, pad=5)

        # insert elements in the container
        rnum=0
        for r in ( (l1, e1, b1), (l2, e2, b2) ):
            cnum=0
            for w in r :
                w.grid(row=rnum, column=cnum ) 
                cnum=cnum+1
            rnum=rnum+1

        self.mvar=IntVar(self)
        mb = Checkbutton(self, text='Use motif stile dialog',
                         variable=self.mvar, command=self.changestyle_callback )
        mb.pack(side=TOP, expand=YES, fill=X )
开发者ID:camilin87,项目名称:learn_python,代码行数:33,代码来源:filebox.py

示例4: __init__

    def __init__(self):
        l = """hree different entries are displayed below.
        You can add characters by pointing, clicking and typing.
        The normal Motif editing characters are supported, along with many
        Emacs bindings.  For example, Backspace and Control-h delete the
        character to the left of the insertion cursor and Delete and
        Control-d delete the chararacter to the right of the insertion cursor.
        For entries that are too large to fit in the window all at once,
        you can scan through the entries by dragging with mouse button2
        pressed.
        """
        DemoWindow.__init__(self, l, 'entry1.py' )

        frame = Frame(self); frame.pack(expand=YES, fill=BOTH)
        w1 = Entry(frame)
        w2 = Entry(frame)
        w3 = Entry(frame)
        for w in w1,w2,w3:
            w.pack(side=TOP, fill=X,padx=5, pady=10 )

        w1.insert(0, 'Initial value')

        w2.insert(0,"This entry contains a value much too long ")
        w2.insert(END,"to fit in the window at one time, so long in fact")
        w2.insert(END," that you will have to scroll or scan to see the end.")
开发者ID:camilin87,项目名称:learn_python,代码行数:25,代码来源:entry1.py

示例5: __init__

    def __init__(self):
        DemoWindow.__init__(self, '', 'tagged-text.py' )

        frame = Frame(self); frame.pack(expand=Y, fill=BOTH )
        text=Text(frame, relief=SUNKEN, bd=2, setgrid=1,
                  wrap='word', height=35);
        text.pack(side=LEFT, expand=Y, fill=BOTH)
        bar=Scrollbar(frame); bar.pack(side=LEFT, fill=Y)
        text['yscrollcommand']=bar.set; bar['command']=text.yview

        self.text = text
        
        self.tags = range(0,6)
        # create and binds the tags
        for t in self.tags:
            self.text.tag_configure (t)
            self.text.tag_bind(t, '<Any-Enter>',
                               callit(self.reconfigure_tag, t, 'bold' ))
            self.text.tag_bind(t, '<Any-Leave>',
                               callit(self.reconfigure_tag, t, 'normal' ))
            self.text.tag_bind(t, '<1>',
                               callit(self.link_callback, t ))
                 
                               
            
        # insert tagged text
        intro = """
The same tag mechanism that controls display styles in text widgets can also be used to associate Tcl commands with regions of text, so that mouse or keyboard actions on the text cause particular Tcl commands to be invoked.  For example, in the text below the descriptions of the canvas demonstrations have been tagged.  When you move the mouse over a demo description the description lights up, and when you press button 1 over a description then that particular demonstration is invoked.


"""
        text.insert('0.0', intro )
        text.insert( END,
                     '1. Samples of all the different types of items that'+
                     ' can be created in canvas widgets.',
                     self.tags[0] )
        text.insert( END, '\n\n');
        text.insert( END,
                     '2. A simple two-dimensional plot that allows you '+
                     'to adjust the positions of the data points.',
                     self.tags[1] )
        text.insert( END, '\n\n');
        text.insert( END,
                     '3. Anchoring and justification modes for text items.',
                     self.tags[2] )
        text.insert( END, '\n\n');
        text.insert( END,
                     '4. An editor for arrow-head shapes for line items.',
                     self.tags[3] )
        text.insert( END, '\n\n');
        text.insert( END,
                     '5. A ruler with facilities for editing tab stops.',
                     self.tags[4] )
        text.insert( END, '\n\n');
        text.insert( END,
                     '6. A grid that demonstrates how canvases can be '+
                     'scrolled.',
                     self.tags[5] )
开发者ID:camilin87,项目名称:learn_python,代码行数:58,代码来源:hypertext.py

示例6: __init__

    def __init__(self):
        DemoWindow.__init__(self, '', 'search.py' )

        frame = Frame(self); frame.pack(expand=Y, fill=BOTH)
        
        # create the controls panel
        c_frame = Frame(frame); c_frame.pack(side=TOP,expand=Y,fill=X)
        c_frame.columnconfigure(1, weight=1,minsize=300 )

        file_l=Label(c_frame, text='File name:');
        file_l.grid(row=0,column=0, sticky='w')

        self.filevar=StringVar(c_frame)
        self.file_e=Entry(c_frame, textvariable=self.filevar );
        self.file_e.grid(row=0, column=1, sticky='ew')
        self.file_e.bind('<Return>', self.load_callback )

        self.load_b =Button(c_frame, text='Load file', padx=10,
                            command=self.load_callback )
        self.load_b.grid(row=0, column=2, sticky='e' )

        string_l=Label(c_frame, text='Search string:')
        string_l.grid(row=1,column=0)

        self.stringvar=StringVar(c_frame)
        self.string_e=Entry(c_frame, textvariable=self.stringvar );
        self.string_e.grid(row=1, column=1, sticky='ew')
        self.string_e.bind('<Return>', self.hilight_callback )

        self.hilight_b =Button(c_frame, text='Hilight', padx=10,
                               command=self.hilight_callback )
        self.hilight_b.grid(row=1, column=2 )

        # create the text widget and related scrollbar
        t_frame = Frame(frame); t_frame.pack(side=TOP,expand=YES,fill=BOTH)
        self.text = Text(t_frame, wrap='word', setgrid=1 )
        self.text.pack(side=LEFT, expand=YES, fill=BOTH )
        vbar = Scrollbar(t_frame, command=self.text.yview )
        vbar.pack(side=LEFT, fill=Y )
        self.text['yscrollcommand'] = vbar.set

        self.text.insert(END,
                         'This window demonstrates how to use the tagging '+
                         'facilities in text widgets to implement a searching '
                         'mechanism.  First, type a file name in the top '+
                         'entry, then type <Return> or click on "Load File".'+
                         'Then type a string in the lower entry and type '+
                         '<Return> or click on "Hilight".  This will cause '+
                         'all of the instances of the string to be tagged ' +
                         'with the tag "search", and it will arrange for the '+
                         'tag\'s display attributes to change to make all '+
                         'of the strings blink.' )

        self.blink='stop'
        self.timer = None

        # set a callback on window closure to remove timer
        self.wm_protocol('WM_DELETE_WINDOW', self.close )
开发者ID:B-Rich,项目名称:widget-tour-py3,代码行数:58,代码来源:search.py

示例7: __init__

    def __init__(self):
        DemoWindow.__init__(self, '', 'text.py' )

        frame = Frame(self); frame.pack(expand=Y, fill=BOTH )
        text=Text(frame, relief=SUNKEN, bd=2, setgrid=1, height=35);
        text.pack(side=LEFT, expand=Y, fill=BOTH)
        bar=Scrollbar(frame); bar.pack(side=LEFT, fill=Y)
        text['yscrollcommand']=bar.set; bar['command']=text.yview

        txt = """
This window is a text widget.  It displays one or more lines of text
and allows you to edit the text.  Here is a summary of the things you
can do to a text widget:

1. Scrolling. Use the scrollbar to adjust the view in the text window.

2. Scanning. Press mouse button 2 in the text window and drag up or down.
This will drag the text at high speed to allow you to scan its contents.

3. Insert text. Press mouse button 1 to set the insertion cursor, then
type text.  What you type will be added to the widget.

4. Select. Press mouse button 1 and drag to select a range of characters.
Once you've released the button, you can adjust the selection by pressing
button 1 with the shift key down.  This will reset the end of the
selection nearest the mouse cursor and you can drag that end of the
selection by dragging the mouse before releasing the mouse button.
You can double-click to select whole words or triple-click to select
whole lines.

5. Delete and replace. To delete text, select the characters you'd like
to delete and type Backspace or Delete.  Alternatively, you can type new
text, in which case it will replace the selected text.

6. Copy the selection. To copy the selection into this window, select
what you want to copy (either here or in another application), then
click button 2 to copy the selection to the point of the mouse cursor.

7. Edit.  Text widgets support the standard Motif editing characters
plus many Emacs editing characters.  Backspace and Control-h erase the
character to the left of the insertion cursor.  Delete and Control-d
erase the character to the right of the insertion cursor.  Meta-backspace
deletes the word to the left of the insertion cursor, and Meta-d deletes
the word to the right of the insertion cursor.  Control-k deletes from
the insertion cursor to the end of the line, or it deletes the newline
character if that is the only thing left on the line.  Control-o opens
a new line by inserting a newline character to the right of the insertion
cursor.  Control-t transposes the two characters on either side of the
insertion cursor.

7. Resize the window.  This widget has been configured with the "setGrid"
option on, so that if you resize the window it will always resize to an
even number of characters high and wide.  Also, if you make the window
narrow you can see that long lines automatically wrap around onto
additional lines so that all the information is always visible.
"""

        text.insert('0.0', txt )
开发者ID:B-Rich,项目名称:widget-tour-py3,代码行数:58,代码来源:text.py

示例8: __init__

    def __init__(self ):
        l = """This window displays a canvas widget containing a
        simple 2-dimensional plot.  You can doctor the data by
        dragging any of the points with mouse button 1."""

        DemoWindow.__init__(self,l, 'canvasplot.py')

        self.canvas = CanvasPlot(self)
        self.canvas.pack(side=TOP)
开发者ID:camilin87,项目名称:learn_python,代码行数:9,代码来源:canvasplot.py

示例9: __init__

    def __init__(self):
        l = """This canvas widget shows a mock-up of a ruler.
        You can create tab stops by dragging them out of the
        well to the right of the ruler.  You can also drag
        existing tab stops.  If you drag a tab stop far enough
        up or down so that it turns dim, it will be deleted when
        you release the mouse button."""
        DemoWindow.__init__(self, l, demo_path('canvasruler.py'))

        self.canvas = RulerCanvas(self)
        self.canvas.pack(expand=YES, fill=BOTH )
开发者ID:codio-packs,项目名称:tkinter-widgets,代码行数:11,代码来源:canvasruler.py

示例10: __init__

    def __init__(self):
        l = """This window displays a canvas widget that can be
        scrolled either using the scrollbars or by dragging with
        button 2 in the canvas.  If you click button 1 on one of
        the rectangles, its indices will displayed.
        You can also drag with button 3 to scroll the canvas.
        """
        DemoWindow.__init__(self,l,demo_path('canvasscroll.py') )

        self.canvas = ScrollableCanvas(self)
        self.canvas.pack(expand='Y', fill='both' )
开发者ID:codio-packs,项目名称:tkinter-widgets,代码行数:11,代码来源:canvasscroll.py

示例11: __init__

    def __init__(self):

        l = ("""This window contains a menubar with cascaded menus.
        You can post a menu from the keyboard by typing %s+x,
        where \"x\" is the character underlined on the menu.
        You can then traverse among the menus using the arrow keys.
        When a menu is posted, you can invoke the current entry by
        typing space, or you can invoke any entry by typing its
        underlined character.  If a menu entry has an accelerator,
        you can invoke the entry without posting the menu just by
        typing the accelerator. The rightmost menu can be torn
        off into a palette by selecting the first item in the menu.
        """ % POST_KEY )
        DemoWindow.__init__(self,l, demo_path('menu.py'))
开发者ID:B-Rich,项目名称:widget-tour-py3,代码行数:14,代码来源:menu.py

示例12: __init__

    def __init__(self):

        l="""This demo shows you two ways of having
        a dialog to grab focus: local and global grab.
        Click on the relevant button and learn about
        the differences"""

        DemoWindow.__init__(self, l, demo_path('dialoggrab.py'))

        frame=Frame(self, relief=RIDGE,border=2); frame.pack(expand=YES,fill=BOTH)
        b1=Button(frame,text='Open dialog with local grab',
                  command=self.localgrab_callback)
        b2=Button(frame,text='Open dialog with global grab',
                  command=self.globalgrab_callback)
        for b in b1,b2: b.pack(side=LEFT, padx=5)
开发者ID:camilin87,项目名称:learn_python,代码行数:15,代码来源:dialoggrab.py

示例13: __init__

    def __init__(self):
        l = """Press the buttons below to choose the foreground and
        background colors for the widgets in this window."""

        DemoWindow.__init__(self,l,demo_path('clrpick.py'))

        frame=Frame(self); frame.pack(expand=YES, fill=BOTH)
        button_fg = Button(frame, text='Foreground',
                                command=self.fg_callback  )
        button_bg = Button(frame, text='Background',
                                command=self.bg_callback )
        for b in button_fg,button_bg:
            b.pack(side=TOP, padx=10, pady=5, expand=YES, fill=X )

        self.all_widgets = ( frame, button_fg, button_bg )
开发者ID:B-Rich,项目名称:widget-tour-py3,代码行数:15,代码来源:clrpick.py

示例14: __init__

    def __init__(self):
        l = """This widget allows you to experiment with different
        widths and arrowhead shapes for lines in canvases.
        To change the line width or the shape of the arrowhead,
        drag any of the three boxes attached to the oversized arrow.
        The arrows on the right give examples at normal scale.
        The text at the bottom shows the configuration options as
        you'd enter them for a canvas line item
        """

        DemoWindow.__init__(self,l,'arrowhead.py' )
        
        self.canvas = ArrowHeadCanvas(self, relief=SUNKEN, border=2,
                             height=350, width=450)
        self.canvas.pack(side=TOP, expand=YES, fill=BOTH )
开发者ID:camilin87,项目名称:learn_python,代码行数:15,代码来源:arrowhead.py

示例15: __init__

    def __init__(self):
        l="""A listbox containing the 50 states is displayed below,
        along with a scrollbar.  You can scan the list either using
        the scrollbar or by scanning.  To scan, press button 2 in
        the widget and drag up or down."""
    
        DemoWindow.__init__(self, l, 'states.py' )

        # create the list
        self.list=HScrollList(self)
        self.list.pack(expand=YES, fill=Y )

        # scroll the list
        for i in StatesDemo.states:
            self.list.list.insert(END,i)
开发者ID:codio-packs,项目名称:tkinter-widgets,代码行数:15,代码来源:states.py


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