Ejemplo n.º 1
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()
Ejemplo n.º 2
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()
Ejemplo n.º 3
0
def do_confirm():
    say("Doing confirm")
    result = confirm("Attack Orpuddex?")
    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),
Ejemplo n.º 4
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))
Ejemplo n.º 5
0
labels = ["Banana", "Chocolate", "Strawberry"]

def report():
    value = grp.value
    try:
        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)
Ejemplo n.º 6
0
        elif c == '\x1b':
            print "Cancel"
        else:
            Window.key_down(self, event)


class TestTextField(TextField):
    def __init__(self, number, *args, **kwds):
        TextField.__init__(self, *args, **kwds)
        self.number = number


nimiLabel = Label("Nimi:")
nimiLabel.position = (20, 20)

grp = RadioGroup()


def set_to_1():
    grp.value = 4


def make_window():
    global win_num
    global tiedot
    nimi = ""
    win_num += 1
    win = TestWindow(size=(320, 200), title="Text fields %d" % (win_num))
    win.tf1 = TestTextField(1,
                            position=(nimiLabel.right + 20, 20),
                            width=200,