Пример #1
0
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()
Пример #2
0
def main():
    global cb1, cb2, rg

    win = Window(title="Place Me By Your Side", width=720, height=500)

    view1 = TestDrawing(width=320, height=200)

    cb1 = CheckBox(title="Check Me!", action=checked_it)

    cb2 = CheckBox(title="Check Me Too!", action=checked_it)

    rbs = []
    for i in range(1, 4):
        rb = RadioButton(title="Hoopy Option %d" % i, value=i)
        rbs.append(rb)

    rg = RadioGroup(rbs, action=option_chosen)

    pb = Button(title="Push Me!", action=pushed_it)

    view2 = TestScrollableDrawing(width=300, height=300)

    label = Label(text="Flavour:")

    entry = TextField(width=200)

    win.place(view1, left=10, top=10, border=1)

    win.place_row([cb1, cb2], left=10, top=(view1, 20), spacing=20)

    win.place_column(rbs, left=view1 + 20, top=10)

    win.place(pb, right=-20, bottom=-10, anchor='rb')

    win.place(view2,
              left=rbs[0] + 20,
              top=10,
              right=-20,
              bottom=pb - 10,
              scrolling='hv',
              anchor='ltrb',
              border=1)

    win.place(label, left=10, top=(cb1, 20))

    win.place(
        entry,
        left=10,
        top=(label, 10),
        #border = 1
    )
    entry.become_target()

    win.show()

    import GUI
    GUI.run()
Пример #3
0
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()
Пример #4
0
    say("Result =", result)


def do_confirm_or_cancel():
    say("Doing confirm_or_cancel")
    result = confirm_or_cancel(
        "Orpuddex is attacking.\nWhat is your response?", "Retaliate",
        "Surrender", "Run Away")
    say("Result =", result)


win = Window(title="Alerts")
rg = RadioGroup()
rb = []
for kind in kinds:
    rb.append(RadioButton(kind.capitalize(), value=kind, group=rg))
rg.set_value('stop')
pb = [
    Button(title="Alert", action=do_alert),
    Button(title="Alert2", action=do_alert2),
    Button(title="Alert3", action=do_alert3),
]
pb2 = [
    Button("Note Alert", action=do_note_alert),
    Button("Stop Alert", action=do_stop_alert),
    Button("Ask", action=do_ask),
    Button("Confirm", action=do_confirm),
    Button("Ask or Cancel", action=do_ask_or_cancel),
    Button("Confirm or Cancel", action=do_confirm_or_cancel),
]
win.place_column(pb, left=20, top=20)
Пример #5
0
    def __init__(self, session, transport, **kwargs):
        title = 'Login'

        self._session = session
        self._transport = transport

        if 'title' in kwargs:
            title = kwargs['title']

        ModalDialog.__init__(self, title=title)

        label = Label('Key File:')
        btn_rsa = RadioButton(title='RSA', value='RSA')
        btn_dss = RadioButton(title='DSS', value='DSS')
        self.key_file_group = key_file_group = RadioGroup(
            items=[btn_rsa, btn_dss])
        key_file_group.value = 'RSA'
        self.txt_key_file = txt_key_file = TextField(multiline=False,
                                                     password=False)
        btn_browse_file = Button('Browse',
                                 action='choose_key_file',
                                 enabled=True)

        lbl_login = Label('Login')
        self.txt_login = TextField(multiline=False, password=False)

        if 'username' in kwargs:
            self.txt_login.text = kwargs['username']

        lbl_passwd = Label('Password')
        self.txt_passwd = TextField(multiline=False, password=True)

        self.ok_button = Button("Connect",
                                action="ok",
                                enabled=True,
                                style='default')
        self.cancel_button = Button("Cancel",
                                    enabled=True,
                                    style='cancel',
                                    action='cancel')

        self.place(label, left=padding, top=padding)
        self.place(btn_rsa, left=label + padding, top=padding)
        self.place(btn_dss, left=btn_rsa + padding, top=padding)
        self.place(txt_key_file,
                   left=padding,
                   top=btn_rsa + padding,
                   right=240)
        self.place(btn_browse_file, left=txt_key_file, top=txt_key_file.top)

        self.place(lbl_login, left=padding, top=txt_key_file + padding)
        self.place(self.txt_login,
                   left=padding,
                   top=lbl_login + padding,
                   right=btn_browse_file.right)

        self.place(lbl_passwd, left=padding, top=self.txt_login + padding)
        self.place(self.txt_passwd,
                   left=padding,
                   top=lbl_passwd + padding,
                   right=btn_browse_file.right)

        self.place(self.cancel_button,
                   top=self.txt_passwd + padding,
                   right=btn_browse_file.right)
        self.place(self.ok_button,
                   top=self.txt_passwd + padding,
                   right=self.cancel_button - padding)
        self.shrink_wrap(padding=(padding, padding))
Пример #6
0
        say(labels[value], "selected")
    except (TypeError, IndexError):
        say("Value =", value)

def set_to_chocolate():
    grp.value = 1

win = Window(width = 250, title = "Radio Groups")

grp = RadioGroup(action = report)

y = 20
for i in range(0, 3):
    rbtn = RadioButton(
        position = (20, y), 
        title = labels[i],
        group = grp, 
        value = i)
    win.add(rbtn)
    y = rbtn.bottom + 5

pbtn = Button(title = "Set to Chocolate",
    position = (20, rbtn.bottom + 20),
    action = set_to_chocolate)
win.add(pbtn)

win.height = pbtn.bottom + 20
win.show()

instructions = """
There should be three radio buttons, "Banana", "Chocolate" and "Strawberry",
Пример #7
0
from GUI import Window, RadioButton, application
from testing import say

btn = RadioButton(x=30, y=30, width=150, title="Radio Button")

win = Window(width=200, height=btn.bottom + 30, title="Radio Button")

win.add(btn)
win.show()

say("The radio button probably won't do anything on its own.")

application().run()