def __init__(self, title, message): title = basic.Label(title) main = table.Table() import app warningIcon = basic.Image( app.App.app.theme.get('warningdialog.warning', '', 'image')) if type(message) is list: if len(message) >= 1: main.tr() main.td(warningIcon, rowspan=len(message), style={'margin': 5}) main.td(basic.Label(message[0]), align=-1) for aMessage in message[1:]: main.tr() main.td(basic.Label(aMessage), align=-1, colspan=2) else: main.tr() main.td(warningIcon) main.td(basic.Label(message), align=-1, colspan=2) main.tr() self.okayButton = button.Button("Okay") self.okayButton.connect(CLICK, self.okayClicked) self.cancelButton = button.Button("Cancel") self.cancelButton.connect(CLICK, self.close) main.td(basic.Spacer(1, 1)) main.td(self.okayButton, align=1, style={'margin': 10}) main.td(self.cancelButton, align=-1, style={'margin': 10}) Dialog.__init__(self, title, main)
def __init__(self, title_txt="File Browser", button_txt="Okay", cls="filedialog", path=None): if not path: self.curdir = os.getcwd() else: self.curdir = path import app self.dir_img = basic.Image(app.App.app.theme.get(cls+'.folder', '', 'image')) td_style = {'padding_left': 4, 'padding_right': 4, 'padding_top': 2, 'padding_bottom': 2} self.title = basic.Label(title_txt, cls=cls+".title.label") self.body = table.Table() self.list = area.List(width=350, height=150) self.input_dir = input.Input(cls=cls+".input") self.input_file = input.Input(cls=cls+".input") self._list_dir_() self.button_ok = button.Button(button_txt) self.body.tr() self.body.td(basic.Label("Path", cls=cls+".label"), style=td_style, align=-1) self.body.td(self.input_dir, style=td_style) self.body.tr() self.body.td(basic.Label("File", cls=cls+".label"), style=td_style, align=-1) self.body.td(self.input_file, style=td_style) self.body.td(self.button_ok, style=td_style) self.body.tr() self.body.td(self.list, colspan=3, style=td_style) self.list.connect(CHANGE, self._item_select_changed_, None) self.button_ok.connect(CLICK, self._button_okay_clicked_, None) self.value = None Dialog.__init__(self, self.title, self.body)
def __init__(self): self.list = area.List(width=350, height=150) okButton = button.Button("Okay", style={ 'width': 80, 'height': 28, 'margin': 8 }) okButton.connect(CLICK, self.okayClicked) cancelButton = button.Button("Cancel", style={ 'width': 80, 'height': 28, 'margin': 8 }) cancelButton.connect(CLICK, self.close) body = table.Table() body.tr() body.td(basic.Label("Select your teacher"), colspan=2) body.tr() body.td(self.list, colspan=2) body.tr() body.td(okButton) body.td(cancelButton) Dialog.__init__(self, basic.Label("Teachers"), body)
def __init__(self, data, menu_cls='menu', **params): params.setdefault('cls', 'menus') table.Table.__init__(self, **params) n, m, mt = 0, None, None for path, cmd, value in data: parts = path.split("/") if parts[0] != mt: mt = parts[0] m = _Menu(basic.Label(mt, cls=menu_cls + ".label"), cls=menu_cls) self.add(m, n, 0) n += 1 m.add(basic.Label(parts[1], cls=m.cls + ".option.label"), cmd, value)
def __init__(self, label=None, image=None, value=None, **params): #TODO label= could conflict with the module label #param image: an imagez.Image object (optional) #param text: a string object params.setdefault('cls', 'list.item') button._button.__init__(self, **params) self.group = None self.value = value #(self, value) self.widget = None if type(label) == str: label = basic.Label(label, cls=self.cls + ".label") if image and label: self.widget = container.Container() self.widget.add(image, 0, 0) #HACK: improper use of .resize() image.rect.w, image.rect.h = image.resize() self.widget.add(label, image.rect.w, 0) elif image: self.widget = image elif label: self.widget = label self.pcls = ""
def __init__(self, value=None, **params): params.setdefault('cls', 'select') table.Table.__init__(self, **params) self.top_selected = button.Button(cls=self.cls + ".selected") table.Table.add(self, self.top_selected) #,hexpand=1,vexpand=1)#,0,0) self.top_selected.value = basic.Label(" ", cls=self.cls + ".option.label") self.top_arrow = button.Button(basic.Image(self.style.arrow), cls=self.cls + ".arrow") table.Table.add(self, self.top_arrow) #,hexpand=1,vexpand=1) #,1,0) self.options = table.Table() #style={'border':3}) self.options_first = None self.options.tr() self.spacer_top = basic.Spacer(0, 0) self.options.add(self.spacer_top) self.options.tr() self._options = table.Table(cls=self.cls + ".options") self.options.add(self._options) self.options.tr() self.spacer_bottom = basic.Spacer(0, 0) self.options.add(self.spacer_bottom) self.options.connect(BLUR, self._close, None) self.spacer_top.connect(CLICK, self._close, None) self.spacer_bottom.connect(CLICK, self._close, None) self.values = [] self.value = value
def __setattr__(self, k, v): if k == 'display' and type(v) == str: v = basic.Label(v, cls=self.cls + ".label") _v = self.__dict__.get(k, NOATTR) self.__dict__[k] = v if k == 'value' and _v != NOATTR and _v != v: self.send(CHANGE) self.repaint()
def __init__(self, title_txt="File Browser", button_txt="Okay", cls="dialog", path=None): """FileDialog constructor. Keyword arguments: title_txt -- title text button_txt -- button text path -- initial path """ cls1 = 'filedialog' if not path: self.curdir = os.getcwd() else: self.curdir = path self.dir_img = basic.Image( pguglobals.app.theme.get(cls1 + '.folder', '', 'image')) td_style = { 'padding_left': 4, 'padding_right': 4, 'padding_top': 2, 'padding_bottom': 2 } self.title = basic.Label(title_txt, cls=cls + ".title.label") self.body = table.Table() self.list = area.List(width=350, height=150) self.input_dir = input.Input() self.input_file = input.Input() self._list_dir_() self.button_ok = button.Button(button_txt) self.body.tr() self.body.td(basic.Label("Folder"), style=td_style, align=-1) self.body.td(self.input_dir, style=td_style) self.body.tr() self.body.td(self.list, colspan=3, style=td_style) self.list.connect(CHANGE, self._item_select_changed_, None) self.button_ok.connect(CLICK, self._button_okay_clicked_, None) self.body.tr() self.body.td(basic.Label("File"), style=td_style, align=-1) self.body.td(self.input_file, style=td_style) self.body.td(self.button_ok, style=td_style) self.value = None Dialog.__init__(self, self.title, self.body)
def __setattr__(self,k,v): if k == 'value' and type(v) == str: v = basic.Label(v,cls=self.cls+".label") _v = self.__dict__.get(k,NOATTR) self.__dict__[k]=v if k == 'value' and v != None: pass if k == 'value' and _v != NOATTR and _v != None and _v != v: self.send(CHANGE) self.chsize()
def __init__(self, title="", default="", editable=True, special_button=None): self.list = area.List(width=350, height=150) self.list.connect(CHANGE, self.itemClicked, None) self.journalItems = [] okButton = button.Button("Okay", style={ 'width': 80, 'height': 28, 'margin': 8 }) okButton.connect(CLICK, self.okayClicked) cancelButton = button.Button("Cancel", style={ 'width': 80, 'height': 28, 'margin': 8 }) cancelButton.connect(CLICK, self.close) self.input_item = input.Input(default) self.input_item.connect(CHANGE, self.itemTyped, None) self.input_item.disabled = not editable body = table.Table() body.tr() body.td(basic.Label(title), colspan=2) body.tr() body.td(self.list, colspan=2) body.tr() if special_button: body.td(self.input_item, colspan=1) body.td(special_button, colspan=1) else: body.td(self.input_item, colspan=2) body.tr() body.td(okButton) body.td(cancelButton) Dialog.__init__(self, basic.Label(title), body)
def __setattr__(self, k, v): mywidget = None if k == 'value': for w in self.values: if w._value == v: mywidget = w _v = self.__dict__.get(k, NOATTR) self.__dict__[k] = v if k == 'value' and _v != NOATTR and _v != v: self.send(CHANGE) self.repaint() if k == 'value': if not mywidget: mywidget = basic.Label(" ", cls=self.cls + ".option.label") self.top_selected.value = mywidget
def __init__(self, title, body, width=400, **params): title = basic.Label(title) creditsLabel = basic.WidthLabel(value=body, width=width) creditsExit = button.Button("Okay", style={ 'width': 80, 'height': 40 }) creditsExit.connect(CLICK, self.close) creditsPanel = document.Document() creditsPanel.add(creditsLabel) creditsPanel.br(10) creditsPanel.br(4) creditsPanel.space((width // 2 - 40, 4)) creditsPanel.add(creditsExit) Dialog.__init__(self, title, creditsPanel)
def __setattr__(self,k,v): if (k == 'value' and isinstance(v, basestring)): # Allow the choice of font to propagate to the button label params = {} if (self.style.font): params["font"] = self.style.font v = basic.Label(v, cls=self.cls+".label", **params) v.container = self _v = self.__dict__.get(k,NOATTR) self.__dict__[k]=v if k == 'value' and v != None: pass if k == 'value' and _v != NOATTR and _v != None and _v != v: self.send(CHANGE) self.chsize()
def add(self, w, value=None): """Add a widget, value item to the Select. <pre>Select.add(widget,value=None)</pre> <dl> <dt>widget<dd>Widget or string to represent the item <dt>value<dd>value for this item </dl> <strong>Example</strong> <code> w = Select() w.add("Goat") #adds a Label w.add("Goat","goat") #adds a Label with the value goat w.add(gui.Label("Cuzco"),"goat") #adds a Label with value goat </code> """ if type(w) == str: w = basic.Label(w, cls=self.cls + ".option.label") w.style.align = -1 b = button.Button(w, cls=self.cls + ".option") b.connect(CLICK, self._setvalue, w) #b = w #w.cls = self.cls+".option" #w.cls = self.cls+".option" if len(self.values) % self.cols == 0: self._options.tr() self._options.add(b) #,align=-1) if self.options_first == None: self.options_first = b #self._options.td(b, align=-1, cls=self.cls+".option") #self._options.td(_List_Item(w,value=value),align=-1) if value != None: w._value = value else: w._value = w if self.value == w._value: self.top_selected.value = w self.values.append(w)
def __init__(self, data, cols=0, rows=0, tool_cls='tool', value=None, **params): print 'gui.Toolbox', 'Scheduled to be deprecated.' params.setdefault('cls', 'toolbox') table.Table.__init__(self, **params) if cols == 0 and rows == 0: cols = len(data) if cols != 0 and rows != 0: rows = 0 self.tools = {} _value = value g = group.Group() self.group = g g.connect(CHANGE, self._change, None) self.group.value = _value x, y, p, s = 0, 0, None, 1 for ico, value in data: #from __init__ import theme import app img = app.App.app.theme.get(tool_cls + "." + ico, "", "image") if img: i = basic.Image(img) else: i = basic.Label(ico, cls=tool_cls + ".label") p = button.Tool(g, i, value, cls=tool_cls) self.tools[ico] = p #p.style.hexpand = 1 #p.style.vexpand = 1 self.add(p, x, y) s = 0 if cols != 0: x += 1 if cols != 0 and x == cols: x, y = 0, y + 1 if rows != 0: y += 1 if rows != 0 and y == rows: x, y = x + 1, 0
def __init__(self, title_txt="File Browser", button_txt="Okay", cls="dialog", path=None, filter=None, default="", favorites=None, special_button=None): cls1 = 'filedialog' self.filter = filter if not path: self.curdir = os.getcwd() else: self.curdir = path import app self.dir_img = basic.Image( app.App.app.theme.get(cls1 + '.folder', '', 'image')) td_style = { 'padding_left': 4, 'padding_right': 4, 'padding_top': 2, 'padding_bottom': 2 } self.title = basic.Label(title_txt, cls=cls + ".title.label") self.body = table.Table() self.list = area.List(width=350, height=150) self.input_dir = input.Input() self.input_file = input.Input(default) self._list_dir_() self.button_redirect = button.Button("Go") self.button_ok = button.Button(button_txt) self.body.tr() self.body.td(basic.Label("Folder"), style=td_style, align=-1) self.body.td(self.input_dir, style=td_style) self.body.td(self.button_redirect, style=td_style) self.button_redirect.connect(CLICK, self._button_redirect_clicked_, None) if favorites or special_button: self.body.tr() d = document.Document() if special_button: d.add(special_button) for icon, text, link in favorites: t = table.Table() t.tr() t.td(basic.Image(icon)) t.tr() t.td(basic.Label(text)) b = button.Button(t) b.connect(CLICK, self._button_redirect_link_, link) d.space((20, 28)) d.add(b) self.body.td(d, colspan=3) self.body.tr() self.body.td(self.list, colspan=3, style=td_style) self.list.connect(CHANGE, self._item_select_changed_, None) self.button_ok.connect(CLICK, self._button_okay_clicked_, None) self.body.tr() self.body.td(basic.Label("File"), style=td_style, align=-1) self.body.td(self.input_file, style=td_style) self.body.td(self.button_ok, style=td_style) self.value = None Dialog.__init__(self, self.title, self.body)