def __init__(self,**params): self.task = gui.Form() # widget values get added to this dict self.state = None title = gui.Label("Task Dialog") table = gui.Table(width=400) # Name input table.tr() table.td(gui.Label("Name:"), colspan=1) table.td(gui.Input(name="name"), colspan=3) table.tr() table.td(gui.Spacer(width=1,height=5)) # Notes input table.tr() table.td(gui.Label("Notes:"), colspan=1) table.td(gui.Input(name="notes"), colspan=3) table.tr() table.td(gui.Spacer(width=1,height=5)) # Due date input table.tr() table.td(gui.Label("Due Date:"), colspan=1) table.td(gui.Input(name="dueDate"), colspan=3) table.tr() table.td(gui.Spacer(width=1,height=5)) # tags checkbox table.tr() table.td(gui.Label("Tags:"), colspan=4, align=0) tagGroup = gui.Group(name="tags") table.tr() table.td(gui.Label("School"), colspan=2, align=1) table.td(gui.Checkbox(tagGroup,value="school")) table.tr() table.td(gui.Label("Work"), colspan=2, align=1) table.td(gui.Checkbox(tagGroup,value="work")) table.tr() table.td(gui.Label("Health"), colspan=2, align=1) table.td(gui.Checkbox(tagGroup,value="health")) table.tr() table.td(gui.Spacer(width=1,height=10)) table.tr() self.saveBtn = gui.Button("Add Task") self.saveBtn.connect(gui.CLICK,self.send,gui.CHANGE) table.td(self.saveBtn, colspan=4) gui.Dialog.__init__(self,title,table)
def __init__(self, value, **params): gui.Table.__init__(self, **params) self.ev_manager = params['ev_manager'] self.gui_form = gui.Form() g = gui.Group(value=[config.use_darkness], name='use_darkness') self.td(gui.Checkbox(g, value=1)) self.td(gui.Label("Darkness")) g.connect(gui.CHANGE, self.changed, None)
def __init__(self, value, **params): gui.Table.__init__(self, **params) self.ev_manager = params['ev_manager'] self.gui_form = gui.Form() g = gui.Group(value=[config.fill_board], name='fill_board') self.td(gui.Checkbox(g, value=1)) self.td(gui.Label("Fill board")) g.connect(gui.CHANGE, self.changed, None)
def start_input(self, attrs): r = self.attrs_to_map(attrs) params = self.map_to_params(r) #why bother #params = {} type_, name, value = r.get('type', 'text'), r.get('name', None), r.get('value', None) f = self.form if type_ == 'text': e = gui.Input(**params) self.map_to_connects(e, r) self.item.add(e) elif type_ == 'radio': if name not in f.groups: f.groups[name] = gui.Group(name=name) g = f.groups[name] del params['name'] e = gui.Radio(group=g, **params) self.map_to_connects(e, r) self.item.add(e) if 'checked' in r: g.value = value elif type_ == 'checkbox': if name not in f.groups: f.groups[name] = gui.Group(name=name) g = f.groups[name] del params['name'] e = gui.Checkbox(group=g, **params) self.map_to_connects(e, r) self.item.add(e) if 'checked' in r: g.value = value elif type_ == 'button': e = gui.Button(**params) self.map_to_connects(e, r) self.item.add(e) elif type_ == 'submit': e = gui.Button(**params) self.map_to_connects(e, r) self.item.add(e) elif type_ == 'file': e = gui.Input(**params) self.map_to_connects(e, r) self.item.add(e) b = gui.Button(value='Browse...') self.item.add(b) def _browse(value): d = gui.FileDialog() d.connect(gui.CHANGE, gui.action_setvalue, (d, e)) d.open() b.connect(gui.CLICK, _browse, None) self._locals[r.get('id', None)] = e
def __init__(self, **params): title = gui.Label("Weibo Word Contrast") container = gui.Container(width=500, height=400) td_style = {'padding_right': 10} ################################# table = gui.Table(width=490, height=300) g = gui.Group() table.tr() table.td(gui.Label("Dlut", style=td_style, cls="h2")) check_box_1 = gui.Checkbox(g, value=1) check_box_1.connect(gui.CLICK, self.get_checked, 1) table.td(check_box_1) table.td(gui.Label("Tsinghua", style=td_style, cls="h2")) check_box_2 = gui.Checkbox(g, value=2) check_box_2.connect(gui.CLICK, self.get_checked, 2) table.td(check_box_2) table.td(gui.Label("Peking", style=td_style, cls="h2")) check_box_3 = gui.Checkbox(g, value=3) check_box_3.connect(gui.CLICK, self.get_checked, 3) table.td(check_box_3) table.tr() table.td(gui.Label("Naking", style=td_style, cls="h2")) check_box_4 = gui.Checkbox(g, value=4) check_box_4.connect(gui.CLICK, self.get_checked, 4) table.td(check_box_4) table.td(gui.Label("Ecupsl", style=td_style, cls="h2")) check_box_5 = gui.Checkbox(g, value=5) check_box_5.connect(gui.CLICK, self.get_checked, 5) table.td(check_box_5) ''' table.tr() table.td(gui.Label("With IDF", style=td_style, cls="h2")) check_box_6 = gui.Checkbox(g, value=6) check_box_6.connect(gui.CLICK, self.get_checked,6) table.td(check_box_6) table.td(gui.Label("Without IDF", style=td_style, cls="h2")) check_box_7 = gui.Checkbox(g, value=7) check_box_7.connect(gui.CLICK, self.get_checked,7) table.td(check_box_7) ''' table.tr() table.td(gui.Label("Show difference", style=td_style, cls="h2")) word_contrast_button = gui.Button("Click") word_contrast_button.connect(gui.CLICK, self.show_word_contrast, -1) table.td(word_contrast_button) table.td(gui.Label("clear", style=td_style, cls="h2")) check_box_7 = gui.Checkbox(g, value=0) check_box_7.connect(gui.CLICK, self.clear_value, 0) table.td(check_box_7) ################################# container.add(table, 1, 10) gui.Dialog.__init__(self, title, container)
c.tr() c.td(gui.Label("Button")) c.td(btn, colspan=3) ## c.tr() c.td(gui.Label("Switch")) c.td(gui.Switch(False), colspan=3) c.tr() c.td(gui.Label("Checkbox")) ##Note how Groups are used for Radio buttons, Checkboxes, and Tools. ##:: g = gui.Group(value=[1, 3]) c.td(gui.Checkbox(g, value=1)) c.td(gui.Checkbox(g, value=2)) c.td(gui.Checkbox(g, value=3)) ## c.tr() c.td(gui.Label("Radio")) g = gui.Group() c.td(gui.Radio(g, value=1)) c.td(gui.Radio(g, value=2)) c.td(gui.Radio(g, value=3)) c.tr() c.td(gui.Label("Select")) e = gui.Select() e.add("Goat", 'goat')
def run(self): """Run the item""" # Initialize the item self.set_item_onset() self.sri = self.time() self.experiment.set("response", None) self.experiment.set("response_time", None) # Create the app self.app = gui.Desktop(item=self) self.app.connect(gui.QUIT, self.app.quit, None) # Create a list of choices choices = [] for choice in self.get("choices").split(";"): choices.append(self.experiment.unsanitize(choice)) pad = 0 # The maximum line length, used to pad the options # Create an HTML document for the content doc = html.HTML("") for l in self.experiment.unsanitize(self.get("question")).split("\n"): doc.add(gui.Label(l)) pad = max(pad, len(l)) doc.br(0) # Determine the colspan if self.get("orientation") == "vertical": span = 2 else: span = len(choices) # Create a 2-column table, start with the HTML on the first row c = gui.Table() c.tr() c.td(doc, colspan=span, align=-1) # A group for the responses group = gui.Group() if self.get("orientation") == "vertical": # In the vertical orientation each choice is in a row for option in choices: l = gui.Label(option.ljust(pad)) if self.get("allow_multiple") == "no": r = gui.Radio(group, value=option) else: r = gui.Checkbox(group, value=option) r.connect(gui.CLICK, self.set_response, option) c.tr() c.td(r, align=-1, width=32, height=32) c.td(l, align=-1, height=32) else: # In the horizontal orientation each choise is in a column # First a row with labels c.tr() for option in choices: l = gui.Label(option) c.td(l, align=-1, height=32) # Next a row with response buttons c.tr() for option in choices: if self.get("allow_multiple") == "no": r = gui.Radio(group, value=option) else: r = gui.Checkbox(group, value=option) r.connect(gui.CLICK, self.set_response, option) c.td(r, align=-1, width=32, height=32) # Add the accept button, if necessary if self.get("accept_on_click") == "no": c.tr() e = gui.Button(self.get("accept_text")) e.connect(gui.CLICK, self.app.quit, None) c.td(e, colspan=span, align=-1, height=32, valign=1) # Keep running the app until a response has been received while True: self.app.run(c) if self.get("response") != "None" or self.get("allow_empty") == "yes": break # Return success return True