def test():
    cursor = StdCursors.empty_cursor()
    win = Window(title = "No Cursor", width = 500, height = 400)
    view = TestDrawing(position = (20, 20), size = (300, 200),
        cursor = cursor)
    win.add(view)
    win.show()
  def __init__(self):
    columns = [Column(*t) for t in [
      ("Day", lambda t: t.date.day),
      ("i?", invoiceableSymbol),
      ("p?", paymentSymbol),
      ("Amount", lambda t: float(t.amount)),
      ("Memo", lambda t: str(t.memo)),
      ]]
    self.transactions_tbl = Table(columns=columns, scrolling='hv',
                                  multi_select=True)

    columns = [
      Column("Month", lambda (y, m): date(y, m, 1).strftime("%Y %b")),
      ]
    rows = D.withSession(Q.allTransactionMonths)
    self.months_tbl = Table(rows=rows, columns=columns, scrolling='v',
                            selection_changed_action=self.month_changed)

    Window.__init__(self, title="Statements", size=(1000, 500))
    self.place(self.months_tbl, left=0, right=100, top=0, bottom=0, sticky='nsw')
    self.place(self.transactions_tbl,
              left=self.months_tbl, right=0, top=0, bottom=0, sticky='nesw')
    self.menus = [
      Menu("Statements", [
          ("Select likely invoiceables/L", "select_likely_invoiceables"),
          ("Mark selection as invoiceable/I", "mark_selection_as_invoiceable"),
          ("Mark selection as payment/P", "mark_selection_as_payment"),
           ]),
           ]
Exemple #3
0
 def make_window(self, document):
     win = Window(size = (400, 400), document = document)
     view = AppView(model = document, extent = (1000, 1000), scrolling = 'hv', #menu_width = 50
         #cursor = self.app_cursor
         )
     win.place(view, left = 0, top = 0, right = 0, bottom = 0, sticky = 'nsew')
     win.show()
def make_window():
    win = Window(size = (240, 100), title = "Password")
    tf = TextField(position = (20, 20), width = 200, password = True)
    ok = Button("OK", position = (20, 60),	action = (show, tf))
    win.add(tf)
    win.add(ok)
    win.show()
 def __init__( self ):
     Window.__init__( self, title='File/channel selection',
                      resizable=False )
     self.selection_frames = []
     self.last_selected_directory = DirRef('.')
     self.enter_button = Button(title='Plot',action=self.plot,width=200)
     self.add_frame()
def test():
    win = Window(title = "Targeting", size = (180, 100))
    patch1 = TestPatch("Red patch", red, position = (20, 20))
    patch2 = TestPatch("Green patch", green, position = (100, 20))
    win.add(patch1)
    win.add(patch2)
    win.show()
    application().run()
 def setup_menus(self, m):
     Window.setup_menus(self, m)
     m.show_selection_cmd.enabled = True
     m.set_selection_cmd.enabled = True
     m.show_text_cmd.enabled = True
     m.set_text_cmd.enabled = True
     m.mono_cmd.enabled = True
     m.sans_cmd.enabled = True
     m.show_tab_spacing_cmd.enabled = True
Exemple #8
0
 def key_down(self, event):
     # print "GDialog.key_down:", repr(event.char) ###
     c = event.char
     if c:
         if c in self._default_keys:
             self.do_default_action()
             return
         elif c in self._cancel_keys:
             self.do_cancel_action()
             return
     Window.key_down(self, event)
 def __init__(self, **kwds):
     Window.__init__(self, **kwds)
     view = TestScrollableView(container = self,
         size = (300, 300),
         extent = (1000, 1000),
         scrolling = 'hv',
         anchor = 'ltrb')
     button = Button("Embedded", action = self.click)
     off = (300, 300)
     view.scroll_offset = off
     button.position = off
     view.add(button)
     self.shrink_wrap()
def make_view(db, options):
    pf = GLConfig(double_buffer = db)
    pf.alpha = "a" in options
    pf.depth_buffer = "d" in options
    pf.stencil_buffer = "s" in options
    pf.aux_buffers = "x" in options
    pf.accum_buffer = "A" in options
    view = TriangleView(pf, size = (200, 200))
    win = Window(
        title = "%s Buffered GLView" % ["Single", "Double"][db],
        size = (240, 240))
    win.place(view, left = 20, top = 20, sticky = "nsew")
    view.become_target()
    win.show()
def test():
    cursor = StdCursors.finger
    win = Window(title = "Cursor", width = 500, height = 400)
    view1 = TestDrawing(position = (20, 20), size = (100, 70), cursor = cursor)
    view2 = TestScrollableView(position = (140, 20), size = (200, 200),
        scrolling = 'hv')
    view2.cursor = cursor
    win.add(view1)
    win.place(view2, sticky = 'nsew')
    win.shrink_wrap((20, 20))
    win.show()
def test():
    file = "grail_masked.tiff"
    # file = "spam_masked.tiff"
    image = Image(os.path.join(sys.path[0], file))
    cursor = Cursor(image)
    win = Window(title="Image Cursor", width=500, height=400)
    view1 = TestDrawing(position=(20, 20), size=(100, 70), cursor=cursor)
    view2 = TestScrollableView(position=(140, 20), size=(200, 200), scrolling="hv")
    view2.cursor = cursor
    win.add(view1)
    win.place(view2, sticky="nsew")
    win.shrink_wrap((20, 20))
    win.show()
def main():
    f = None
    args = sys.argv[1:]
    if args:
        fontsize = int(args[0])
        sf = StdFonts.system_font
        f = Font(sf.family, fontsize, sf.style)
        #showfont("Using font", f)
    win = Window(title = "Heights")
    if f:
        kwds = {'font': f}
    else:
        kwds = {}
    controls = [
        Label(text = "Label", **kwds),
        TextField(text = "Text", **kwds),
        CheckBox(title = "Check", **kwds),
        RadioButton(title = "Radio", **kwds),
        Slider(orient = 'h', width = 50),
        #Button(title = "Button", **kwds),
    ]
    #for ctl in controls:
    #	say("Height of %r is %s" % (ctl, ctl.height))
    win.place_row(controls, left = 10, top = 10)
    win.shrink_wrap(padding = (10, 10))
    win.show()
    run()
Exemple #14
0
def main():
    win = Window()
    view = PolyView(width=120, height=120)
    win.add(view)
    win.shrink_wrap()
    win.show()
    application().run()
def test():
    view = TestView(size = (300, 200))
    win = Window(title = "Coloured Text")
    win.add(view)
    win.shrink_wrap()
    win.show()
    run()
def test():
    def bing():
        say("Bing!")
        #fld._win_dump_flags()
    win = Window(title = "Shrink Wrap", resizable = 0)
    but = Button("Bing!", action = bing)
    cbx = CheckBox("Spam")
    fld = TextField(width = 100)
    win.place(but, left = 20, top = 20)
    win.place(cbx, left = but + 20, top = 20)
    win.place(fld, left = 20, top = but + 20)
    win.shrink_wrap()
    win.show()
    application().run()
Exemple #17
0
 def make_window(self, document):
     
     window_width = 800
     window_height = 600
     
     #create a Window object and associate it with our document 
     #so when the window is closed the doc can ask the user if
     #he wants to save
     app_window = Window(size = (window_width, window_height), document = document)
     
     #make a view for the window
     app_view = LineView(model = document, extent = (window_width, window_height), printable = False, cursor = self.line_cursor)
     
     #place the view in the window, make it resizeable
     app_window.place(app_view, left = 0, top = 0, right = 0, bottom = 0, sticky = 'nsew')
     
     #display the window when we are done initializing
     app_window.show()
def test():
    win = Window(title = "Exceptions", size = (200, 100))
    but1 = Button("ApplicationError", action = raise_application_error)
    but2 = Button("Exception", action = raise_exception)
    win.place_column([but1, but2], left = 20, top = 20)
    win.shrink_wrap(padding = (20, 20))
    win.show()
    application().run()
def test():
    view = GearsView(size = (300, 300))
    win = Window(title = "Gears")
    win.place(view, sticky = "nsew")
    view.become_target()
    win.shrink_wrap()
    win.show()
    application().run()
def test():
    starter = Button("Start", action = start_task)
    stopper = Button("Stop", action = stop_task)
    win = Window(title = "Tasks")
    win.place_column([starter, stopper], left = 20, top = 20, spacing = 20)
    win.shrink_wrap(padding = (20, 20))
    win.show()
    application().run()
 def __init__(self):
     Window.__init__(self, size = (200, 200))
     self.filt = CheckBox("%ss only" % self.file_type.name)
     #self.multi = CheckBox("Multiple Selection")
     buts = []
     if 'request_old_file' in functions:
         buts.append(Button("Old File", action = self.do_old_file))
     if 'request_old_files' in functions:
         buts.append(Button("Old Files", action = self.do_old_files))
     if 'request_new_file' in functions:
         buts.append(Button("New File", action = self.do_new_file))
     if 'request_old_directory' in functions:
         buts.append(Button("Old Directory", action = self.do_old_dir))
     if 'request_old_directories' in functions:
         buts.append(Button("Old Directories", action = self.do_old_dirs))
     if 'request_new_directory' in functions:
         buts.append(Button("New Directory", action = self.do_new_dir))
     self.place_column([self.filt] + buts, left = 20, top = 20)
     self.shrink_wrap(padding = (20, 20))
Exemple #22
0
def main():
    view = CTV(size=(200, 300))
    win = Window(title="Canvas")
    win.add(view)
    win.shrink_wrap()
    view.become_target()
    win.show()
    app = application()
    app.menus = basic_menus() + [test_menu]
    app.run()
def test():
    def select():
        i = group.value
        name = cursor_names[i]
        say("Selecting cursor no. %d (%s)" % (i, name))
        cursor = getattr(StdCursors, name)
        say("...", cursor)
        view.cursor = cursor
    win = Window(title = "Std Cursors")
    view = TestArea(size = (100, 100))
    win.place(view, left = 20, top = 20)
    group = RadioGroup(action = select)
    for i, name in enumerate(cursor_names):
        group.add_item(RadioButton(title = name, value = i))
    win.place_column(group, left = view + 20, top = 20, spacing = 0)
    win.shrink_wrap((20, 20))
    win.show()
    application().run()
def test():
    win = Window(title = "Frame")
    frm = Frame()
    frm.place_column([
        Label("This is"),
        Label("A frame")],
        left = 0, top = 0)
    frm.shrink_wrap()
    win.place(frm, left = 30, top = 30)
    win.shrink_wrap(padding = (30, 30))
    win.show()
def test():
    app = application()
    pixmap = GLPixmap(50, 50, double_buffer = False, alpha = False)
    pixmap.with_context(draw_triangle, flush = True)
    #pixmap.with_canvas(draw_circle)
    view = PixmapTestView(pixmap, size = (180, 200))
    win = Window(title = "GLPixmap", resizable = False)
    win.add(view)
    win.shrink_wrap()
    win.show()
    app.run()
def test():
    doc = TestDoc(title = "Document")
    view = TestDocView(model = doc, size = (200, 200))
    win = Window(resizable = 0, size = (200, 200))
    win.add(view)
    win.document = doc
    #say(view.x, view.y, view.width, view.height)
    win.show()
    application().run()
 def __init__(self, **kwds):
     Window.__init__(self, **kwds)
     self.view = TestScrollableView(container = self,
         x = 20, y = 20,
         width = 300, height = 300)#, scrolling = 'hv')
     self.view.report_update_rect = True
     if 1: ###
         self.h_scrolling_ctrl = CheckBox("Horizontal Scrolling",
             value = 'h' in self.view.scrolling, 
             action = 'horz_scrolling')
         self.v_scrolling_ctrl = CheckBox("Vertical Scrolling",
             value = 'v' in self.view.scrolling,
             action = 'vert_scrolling')
         self.border_ctrl = CheckBox("Border", value = 1, action = 'change_border')
         CheckBox("Vertical Scrolling", value = 1, action = 'vert_scrolling'),
         buttons = self.create_buttons()
         x = self.view.right + 5
         y = self.view.top
         for b in buttons:
             b.position = (x, y)
             self.add(b)
             y = b.bottom + 5
         #self.shrink_wrap()
         self.view.become_target()
def test(orient, pos, pad):
    win = Window(title = "%s Sliders" % orient.upper(), position = pos,
        auto_position = False)
    sliders = []
    if 1:
        #say("Creating slider 1")
        sl1 = sl2 = sl3 = None
        sl1 = Slider(orient = orient, max_value = 100)
        sl1.action = slid(sl1, orient, 1)
        sliders.append(sl1)
    if 1:
        #say("Creating slider 2")
        sl2 = Slider(orient = orient, max_value = 100, ticks = 6, live = False)
        sl2.value = 50
        sl2.action = slid(sl2, orient, 2)
        sliders.append(sl2)
    if 1:
        #say("Creating slider 3")
        sl3 = Slider(orient = orient, max_value = 100, ticks = 6, discrete = True)
        sl3.value = 100
        sl3.action = slid(sl3, orient, 3)
        sliders.append(sl3)
    #say("Created sliders")
    if orient == 'h':
        win.place_column(sliders, left = 20, top = 20, spacing = 20, sticky = 'ew')
        if sl2:
            sl2.vstretch = True
        if sl3:
            sl3.vmove = True
    else:
        win.place_row(sliders, left = 20, top = 20, spacing = 20, sticky = 'ns')
        if sl2:
            sl2.hstretch = True
        if sl3:
            sl3.hmove = True
    #say("Placed sliders")
    win.shrink_wrap()
    win.show()
Exemple #29
0
    def open_soldier_chooser(self, blob, defender, x, y):
        win = Window(size=(220, 100), style='nonmodal_dialog')
        button = Button('Attack')
        text_field = TextField()
        button.style = 'normal'
        slider = Slider('h')

        def set_textfield():
            text_field.set_text(str(int(slider.get_value())))

        def start_conquering():
            winner = war(blob, defender, int(slider.get_value()))
            looser = blob if winner != blob else defender
            soldiers_left = int(slider.get_value() - (slider.max_value+1 - blob.get_soldiers()))
            conquer_territory(winner, looser, soldiers_left)
            self.model.set_blob_position(blob, x, y)
            print "Winner is: " + winner.territory.get_owner() + "!"
            win.destroy()

        if blob.get_soldiers() - 1 != 1:
            slider.max_value = blob.get_soldiers() - 1
            slider.min_value = 1
            slider.ticks = blob.get_soldiers() - 1
            slider.discrete = True
            slider.action = set_textfield
            button.action = start_conquering
            win.place(slider, left=0, top=10, right=220, bottom=50)
            win.place(button, left=15, top=50, right=55, bottom=90)
            win.place(text_field, left=170, top=50, right=210, bottom=70)
            win.show()
        else:
            winner = war(blob, defender, 1)
            looser = blob if winner != blob else defender
            soldiers_left = int(slider.get_value()) - (int(slider.max_value) - blob.get_soldiers())
            conquer_territory(winner, looser, soldiers_left)
            self.model.set_blob_position(blob, x, y)
            print "Winner is: " + winner.territory.get_owner() + "!"
from GUI import Window, ListButton, application
from testing import say

def report():
    print "Value =", but.value

but = ListButton(position = (20, 20),
    titles = ["Item %d" % i for i in xrange(30)],
    action = report)
but.value = 42
win = Window(title = "List Button")
win.add(but)
but.become_target()
win.show()

instructions = """
There should be a list button containing 30 items.
   
Selecting an item should cause its value to be reported. On Windows,
it should be possible to make a selection by typing the first letter
of the title.
"""

say(instructions)
application().run()