Exemplo n.º 1
0
 def __init__(self, label, stock_image):
     gtk.Button.__init__(self, label)
     Observable.__init__(self)
     self.image = gtk.Image()
     self.image.set_from_stock(stock_image, gtk.ICON_SIZE_MENU)
     self.set_image(self.image)
     self.connect("clicked", self._OnClick)
Exemplo n.º 2
0
    def __init__(self):
        self.store = StringStore(4)
        gtk.TreeView.__init__(self, model=self.store)
        Observable.__init__(self)
        self.get_selection().set_mode(gtk.SELECTION_SINGLE)

        self.set_property("rules-hint"   , True)
        self.set_property("enable-search", False)
        
        for n, (title, xalign, expand) in enumerate((
            (u"Beskrivelse"        , 0., True ),
            (u"Antal"              , 1., False),
            (u"Indkøbspris (total)", 1., False),
            (u"Salgspris (total)"  , 1., False),
        )):
            coll = gtk.TreeViewColumn()
            cell = gtk.CellRendererText()
            coll.pack_start(cell)
            coll.set_property("title", title)
            coll.set_property("sizing", gtk.TREE_VIEW_COLUMN_AUTOSIZE)
            coll.set_property("expand", expand)
            coll.add_attribute(cell, 'text', n)
            cell.set_property("xalign", 0)
            self.append_column(coll)

        self.connect("focus-in-event", self.OnFocusIn)
        self.connect("focus-out-event", self.OnFocusOut)
Exemplo n.º 3
0
    def __init__(self):
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
        Observable.__init__(self)
        vbox = gtk.VBox()
        menu = MenuBar()
        tabs = MainTabs()

        self.acg = gtk.AccelGroup()
        self.add_accel_group(self.acg)
        
        self.add(vbox)
        vbox.add(menu)
        vbox.add(tabs)
        
        self.get_settings().set_long_property("gtk-button-images", True, "")
        self.set_property("default-height", 400              )
        self.set_property("default-width" , 400              )
        self.set_property("title"         , u"RKG Ølregnskab")
        vbox.child_set_property(menu, "expand", False)

        self.connect("destroy", self._on_destroy)
        
        tabs.observers.add("add_product", self._on_add_product)
        
        self.show_all()
        
        self.tabs = tabs
Exemplo n.º 4
0
 def __init__(self, sell_val, buy_val, name = None, count = None, misc = None):
     Observable.__init__(self)
     self._buy_val = buy_val
     self._sell_val = sell_val
     self._name = name
     self._count = count
     self._misc = misc
Exemplo n.º 5
0
 def __init__(self, toplevel):
     gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
     Observable.__init__(self)
     for key, value in (
         ("title"          , u"Opret produkt"),
         ("transient-for"  , toplevel),
         ("modal"          , True),
         ("window-position", gtk.WIN_POS_CENTER_ON_PARENT),
     ):
         self.set_property(key, value)
     
     form = ProductForm()
     form.observers.add("submit", self._OnSubmit)
     form.observers.add("cancel", self._OnCancel)
     acg = gtk.AccelGroup()
     
     # Escape, Enter, Keypad Enter
     for (key, callback) in (
         (65307, form.cancel), # Escape
         (65293, form.submit), # Enter
         (65421, form.submit), # Keypad Enter
     ):
         acg.connect_group(key, 0, 0, lambda *args: callback()) # Escape
     
     self.add_accel_group(acg)
     self.add(form)
     self.show_all()
Exemplo n.º 6
0
 def __init__(self, name=None, email=None, type=None, entries=[], misc=None):
     Observable.__init__(self)
     self._name = name
     self._email = email
     self._type = type
     self._entries = entries
     self._misc = misc
Exemplo n.º 7
0
    def __init__(self, treeview):
        gtk.VBox.__init__(self)
        Observable.__init__(self)

        for label, stock, action in (
            ("_Tilføj" , gtk.STOCK_ADD   , self._OnAdd),
            ("_Redigér", gtk.STOCK_EDIT  , self._OnEdit),
            ("_Slet"   , gtk.STOCK_DELETE, self._OnDelete),
        ):
            button = StockButton(label, stock)
            button.observers.add("clicked", action)
            self.add(button)
            self.child_set_property(button, "expand", False)
Exemplo n.º 8
0
 def __init__(self):
     gtk.VBox.__init__(self)
     Observable.__init__(self)
    
     self.title = u"Produkter"
     
     table = ProductTable()
     
     vbox = gtk.VBox()
     hbox = gtk.HBox()
     scrollwin = gtk.ScrolledWindow()
     
     options = OptionsContainer(table)
     
     def add():
         dialog = ProductDialog(self.get_toplevel())
         def submit(name, sell_val, buy_val, misc):
             self.observers.notify("add_product", name, sell_val, buy_val, misc)
         dialog.observers.add("submit", submit)
     options.observers.add("add", add)
     
     def delete():
         table.remove_selection()
     options.observers.add("delete", delete)
     
     for parent, child in (
         (self, hbox),
             (hbox, vbox),
                 (vbox, scrollwin),
                     (scrollwin, table),
             (hbox, options),
     ):
         parent.add(child)
         
     for widget, name, value in (
         (self     , "spacing"          , 0                ),
         (vbox     , "spacing"          , 0                ),
         (hbox     , "spacing"          , 0                ),
         (scrollwin, "vscrollbar-policy", gtk.POLICY_AUTOMATIC),
         (scrollwin, "hscrollbar-policy", gtk.POLICY_NEVER ),
         (scrollwin, "shadow-type"      , gtk.SHADOW_IN    ),
     ):
         widget.set_property(name, value)
         
     hbox.child_set_property(options, "expand", False)
     hbox.child_set_property(vbox   , "expand", True )
     
     self.table = table
Exemplo n.º 9
0
    def __init__(self):
        gtk.Notebook.__init__(self)
        Observable.__init__(self)

        productbox = ProductBox()
        
        def add_product(name, sell_val, buy_val, misc):
            self.observers.notify("add_product", name, sell_val, buy_val, misc)
        productbox.observers.add("add_product", add_product)

        self.set_property("show-border", False)
        self.set_property("homogeneous", True )
        
        self.append_page(productbox, gtk.Label(u"Produkter"))
        
        self.productbox = productbox
Exemplo n.º 10
0
 def __init__(self, amount, date=None):
     Observable.__init__(self)
     self.amount = amount
     self.date = date
Exemplo n.º 11
0
    def __init__(self):
        gtk.VBox.__init__(self)
        Observable.__init__(self)
        
        table          = gtk.Table()
        name_entry     = gtk.Entry()
        sell_val_entry = gtk.Entry()
        buy_val_entry  = gtk.Entry()
        misc_entry     = gtk.Entry()
        buttons        = gtk.HButtonBox()
        button_cancel  = StockButton(u"_Annullér", gtk.STOCK_CANCEL)
        button_submit  = StockButton(u"_Gem", gtk.STOCK_SAVE)

        button_submit.observers.add("clicked", self.submit)
        button_cancel.observers.add("clicked", self.cancel)
        
        for parent, child in (
            (self, table),
            (self, buttons),
                (buttons, button_cancel),
                (buttons, button_submit),
        ):
            parent.add(child)
 
        for (n, (label_text, item)) in enumerate((
            (u"Produktnavn:", name_entry    ),
            (u"Indkøbspris:", buy_val_entry ),
            (u"Salgspris:"  , sell_val_entry),
            (u"Andet:"      , misc_entry    ),
        )):
            label = gtk.Label(label_text)
            label.set_property("xalign", 0.)
            label.set_property("yalign", 0.)
            
            table.attach(
                child = label,
                left_attach = 0,
                right_attach = 1,
                top_attach = n,
                bottom_attach = n + 1,
                ypadding = 5,
                yoptions=gtk.SHRINK|gtk.FILL,
                xoptions=gtk.SHRINK|gtk.FILL
            )
            table.attach(
                child = item,
                left_attach = 1,
                right_attach = 2,
                top_attach = n,
                bottom_attach = n + 1,
                yoptions = gtk.SHRINK,
                xoptions = gtk.FILL|gtk.EXPAND
            )
        
        # Bottom window filler
        table.attach(gtk.HBox(),
            left_attach = 0,
            right_attach = 2,
            top_attach = 4,
            bottom_attach = 5,
            yoptions = gtk.EXPAND|gtk.FILL
        )
        
        
        for widget, key, val in (
            (table         , "column-spacing", 15               ),
            (table         , "row-spacing"   , 4                ),
            (self          , "border-width"  , 10               ),
            (sell_val_entry, "text"          , "0,00"           ),
            (buy_val_entry , "text"          , "0,00"           ),
            (buttons       , "layout-style"  , gtk.BUTTONBOX_END)
        ):
            widget.set_property(key, val)
        
        self.name_entry     = name_entry
        self.sell_val_entry = sell_val_entry
        self.buy_val_entry  = buy_val_entry
        self.misc_entry     = misc_entry
        
        self.child_set_property(buttons, "expand", False)
Exemplo n.º 12
0
 def __init__(self, colcount):
     cols = [gobject.TYPE_STRING for _ in range(colcount)]
     cols += [gobject.TYPE_PYOBJECT]
     self.colcount = colcount
     gtk.ListStore.__init__(self, *cols)
     Observable.__init__(self)