def __init__(self, record, parent): from ProvCon.dbui.di import rLocation MyNode.__init__(self, record, parent) self.records = orm.RecordList ( meta.Table.Get("location"), select=["number", "handle"], order='number', recordclass=rLocation, _filter = 'buildingid = %d' % record.objectid ) self.__childclass__ = LocationNode
def __init__(self, record, parent): MyNode.__init__(self, record, parent) self.records = orm.RecordList ( meta.Table.Get("building"), select=["number"], order='number', _filter = 'streetid = %d' % record.objectid ) self.__childclass__ = BuildingNode
def __init__(self): self.records = orm.RecordList ( meta.Table.Get("city"), select=["name"], order='name' ) self.records.reload() self.parent = None self.children = map ( lambda x: None, self.records )
def __init__(self, record, parent): MyNode.__init__(self, record, parent) self.records = orm.RecordList ( meta.Table.Get("street"), select=["name", "prefix"], order='name', _filter = 'cityid = %d' % record.objectid ) self.__childclass__ = StreetNode
def __init__(self, parent, **kwargs): wx.Panel.__init__ (self, parent, style=wx.SUNKEN_BORDER | wx.TAB_TRAVERSAL) self.tablename = kwargs.get ( "tablename", None) self.table = kwargs.get ( "table", None) self.form = kwargs.get ( "form", None ) if self.tablename: self.table = meta.Table.Get ( self.tablename ) if self.table: self.tablename = self.table.name self.form = orm.Form ( self.table ) if self.form: self.table = self.form.table self.tablename = self.table.name self.save = conditionalmethod ( self.form.save ) self.reload = conditionalmethod ( self.form.revert ) self.new = conditionalmethod ( self.new ) self.delete = conditionalmethod (self.form.delete ) self.on_toolbar_SAVE = self.save self.on_toolbar_NEW = self.new self.on_toolbar_RELOAD = self.reload self.on_toolbar_DEL = self.delete self.mainsizer = wx.BoxSizer (wx.VERTICAL) self.toolbarconfig = kwargs.get ( "toolbar", FormToolbar) #tool bar if self.toolbarconfig: self.toolbar = self.toolbarconfig(self, **kwargs) self.mainsizer.Add ( self.toolbar, flag=wx.EXPAND ) else: self.toolbar = None self.status = wx.StaticText ( self ) self.status.SetFont ( wx.Font ( 8, wx.FONTFAMILY_MAX, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD ) ) self.status.ForegroundColour = (122,66,66) self.status.SetThemeEnabled (False ) self.mainsizer.Add ( self.status, flag=wx.EXPAND | wx.ALL, border=5 ) #editor self.editor_scrolled_window = wx.ScrolledWindow ( self, style=wx.VSCROLL | wx.TAB_TRAVERSAL ) self.editor = GenericForm ( self.form, self.editor_scrolled_window ) self.editor.create_widget() self.scrolledsizer = wx.BoxSizer() self.scrolledsizer.Add ( self.editor, flag=wx.EXPAND ) self.editor_scrolled_window.SetSizer ( self.scrolledsizer ) self.editor_scrolled_window.SetScrollbars(20,20,50,50) self.mainsizer.Add ( self.editor_scrolled_window, 1, flag=wx.EXPAND ) #navigator navigator_config = kwargs.get ( "navigator", Navigator ) navigator_options = kwargs.get ( "navigatoroptions", {} ) if navigator_config: navigator = navigator_config(self, **navigator_options) self.recordlist = orm.RecordList (self.form.table).reload() navigator.set_records ( self.recordlist ) navigator.first() self.mainsizer.Add ( navigator, flag=wx.EXPAND ) else: navigator = None self.SetSizer ( self.mainsizer ) self.SetSize ( parent.GetSize() ) #handlers self.editor_scrolled_window.Bind ( wx.EVT_SIZE, self.on_resize) self.editor.Bind ( wx.EVT_SIZE, self.on_editor_resize ) if navigator: self.set_navigator ( navigator ) self.form.listenForEvent ( "request_record_change", self.before_record_change ) self.form.listenForEvent ( "current_record_modified", self.current_record_modified ) self.form.listenForEvent ( "current_record_deleted", self.current_record_deleted ) self.form.listenForEvent ( "current_record_saved", self.current_record_saved ) self.form.listenForEvent ( "data_loaded", self.data_loaded ) self.infowindow = InfoPopup(self)
def __init__(self, parent, *args): from ProvCon.dbui.di import rSubscriber wx.Panel.__init__(self, parent, *args) self.form = AttrDict() self.table = AttrDict() self.editor = AttrDict() self.store = AttrDict() self.recordlist = AttrDict() self.dialogs = AttrDict() self.dialogs.service = ServiceDialog(self) self.dialogs.subscriber = NewSubscriberDialog(self) self.table.subscriber = meta.Table.Get("subscriber") self.table.service = meta.Table.Get("service") self.store.subscriber = APP.DataStore.subscriber self.store.services = orm.RecordList( self.table.service, select=["classofservice", "typeofservice", "handle"]) self.form.subscriber = orm.Form(self.table.subscriber, recordclass=rSubscriber) subscriberRec = self.form.subscriber.current subscriberRec.enableChildren() self.mgr = wx.aui.AuiManager() self.mgr.SetManagedWindow(self) subscroll = ScrolledGenericForm(self.form.subscriber, self) self.editor.subscriber = subscroll.genericform self.info_panel = SubscriberInfoPanel(self, self.form.subscriber) self.command_panel = SubscriberCommandPanel(self, self.form.subscriber) def _format_service(r): return "<b>" + r.typeofservice_REF + "</b> " + r.classofservice_REF + "<br><i>" + r.locationid_REF + "</i>" def _format_ip(r): return "<b>" + r.address + "</b>" def _format_mac(r): fmt = "<tt><b>" + r.mac + "</b></tt> " if r.ipreservationid: fmt += " -> <b>" + r.ipreservationid_REF + "</b>" return fmt def _format_device(r): return r._astxt #self.recordlist.services = rl.RecordList(self.store.services, self, # reprfunc = _format_service) self.recordlist.services = rl.RecordList( subscriberRec.list_service_subscriberid, self, reprfunc=_format_service) self.recordlist.services.set_menu( ServiceListMenu(self, self.recordlist.services)) self.recordlist.ip = rl.RecordList(subscriberRec.ipreservations, self, reprfunc=_format_ip) self.recordlist.ip.set_menu(IPListMenu(self, self.recordlist.ip)) self.recordlist.mac = rl.RecordList(subscriberRec.macaddresses, self, reprfunc=_format_mac) self.recordlist.mac.set_menu(MACListMenu(self, self.recordlist.mac)) self.recordlist.devices = rl.RecordList(subscriberRec.devices, self, reprfunc=_format_device) self.recordlist.devices.set_menu( DeviceListMenu(self, self.recordlist.devices)) #self.recordlist.services.bind_to_form ( "subscriberid", self.form.subscriber) self.mgr.AddPane( self.info_panel, wx.aui.AuiPaneInfo().Top().Floatable(False).CloseButton( False).Caption("Podsumowanie danych klienta").Name( "info_panel").Layer(1).MinSize((-1, 100)).BestSize( (700, 170))) self.mgr.AddPane( SubscriberSearchToolbar(self), wx.aui.AuiPaneInfo().Bottom().CloseButton(True).Floatable( False).Dockable(False).Show().Name("search_results").Caption( "Wyniki wyszukiwania...").Layer(1).MinSize((-1, 40))) self.mgr.AddPane( subscroll, wx.aui.AuiPaneInfo().CentrePane().Floatable(False).CloseButton( False).Name("subscriber_editor").Layer(0)) self.mgr.AddPane( self.recordlist.services, wx.aui.AuiPaneInfo().Bottom().Floatable(False).CloseButton(False). Name("service_list").Layer(0).Row(1).Caption("Usługi").MinSize( (-1, 120))) self.mgr.AddPane( self.recordlist.devices, wx.aui.AuiPaneInfo().Bottom().Floatable(False).CloseButton(False). Name("device_list").Layer(0).Row(0).Caption("Urządzenia").MinSize( (-1, 160))) self.mgr.AddPane( self.command_panel, wx.aui.AuiPaneInfo().Left().Floatable(False).CloseButton(False). Name("command_panel").Caption("Toolbox").Layer(1).MinSize( (100, -1))) self.mgr.AddPane( self.recordlist.mac, wx.aui.AuiPaneInfo().Right().CloseButton(False).Floatable(False). Name("mac_address_list").Caption("MAC").Layer(1).MinSize( (300, -1))) self.mgr.AddPane( self.recordlist.ip, wx.aui.AuiPaneInfo().Right().CloseButton(False).Floatable(False). Name("ip_address_list").Caption("Adresy IP").Layer(1).MinSize( (300, -1))) self.mgr.Update() f = self.form.subscriber f.listenForEvent("request_record_change", self.subscriberRecordChange) f.listenForEvent("current_record_modified", self.subscriberRecordModified) f.listenForEvent("current_record_deleted", self.subscriberRecordDeleted) f.listenForEvent("current_record_saved", self.subscriberRecordSaved) f.listenForEvent("data_loaded", self.subscriberDataLoaded)
def OnInit(self): self.toplevel = wx.Frame(None, title="Provisioning meta-data editor", size=(1100, 800)) sizer = wx.BoxSizer(wx.VERTICAL) hsizer = wx.BoxSizer(wx.HORIZONTAL) lsizer = wx.BoxSizer(wx.VERTICAL) ##table info editor self.tableeditor = guitk.complete.CompleteGenericForm( self.toplevel, tablename="table_info", navigator=False, no_NEW=True, no_DEL=True) lsizer.Add(self.tableeditor, 4, flag=wx.EXPAND) fieldinfotable = meta.Table.Get("field_info") self.fieldrecords = orm.RecordList( fieldinfotable, select=['lp', 'name', 'path', 'label'], order="lp") self.fieldrecords.filterfunc = lambda r: r.name not in meta.Table.__special_columns__ def _fieldrepr(r): return '#{0.lp}. <b>{0.path}</b><br> <i>{0.label}</i><hr>'.format( r) self.fieldlist = guitk.recordlists.RecordList(self.fieldrecords, self.toplevel, reprfunc=_fieldrepr) self.fieldlist.bind_to_form("classid", self.tableeditor.form) lsizer.Add(self.fieldlist, 2, flag=wx.EXPAND) rsizer = wx.BoxSizer(wx.VERTICAL) self.fieldeditor = guitk.complete.CompleteGenericForm( self.toplevel, table=fieldinfotable, navigator=False, no_NEW=True, no_DEL=True) self.fieldeditor.set_navigator(self.fieldlist) rsizer.Add(self.fieldeditor, 1, flag=wx.EXPAND) hsizer.Add(lsizer, 1, flag=wx.EXPAND) hsizer.Add(rsizer, 1, flag=wx.EXPAND) sizer.Add(hsizer, 1, flag=wx.EXPAND) tablenav = guitk.navigators.Navigator(self.toplevel, records=APP.DataStore.table_info) #tablenav.set_records ( orm.RecordList ( self.tableeditor.table ).reload() ) #tablenav.set_records ( APP.DataStore.table_info ) sizer.Add(tablenav, 0, flag=wx.EXPAND) tablenav.navigate(0) tablenav.Show() self.tableeditor.set_navigator(tablenav) self.toplevel.SetSizer(sizer) menu = wx.MenuBar() menu_data = wx.Menu() mi_export = menu_data.Append(wx.NewId(), "&Export", "Export meta-data to a text file.") mi_import = menu_data.Append(wx.NewId(), "&Import", "Import meta-data to a text file.") self.Bind(wx.EVT_MENU, self.ExportData, id=mi_export.GetId()) self.Bind(wx.EVT_MENU, self.ImportData, id=mi_import.GetId()) menu.Append(menu_data, "&Data") self.toplevel.SetMenuBar(menu) self.toplevel.Show() return True