def get_latex_buffer(self, path, schedule): latex_buffer = misc.LatexFile() cmb_local_vars = {} cmb_local_vars['$cmbbookno$'] = self.name cmb_local_vars['$cmbheading$'] = ' ' cmb_local_vars['$cmbtitle$'] = 'DETAILS OF MEASUREMENTS' cmb_local_vars['$cmbstartingpage$'] = str(1) latex_buffer.add_preffix_from_file( misc.abs_path('latex', 'preamble.tex')) latex_buffer.replace_and_clean(cmb_local_vars) for count, item in enumerate(self.items): newpath = list(path) + [count] latex_buffer += item.get_latex_buffer(newpath, schedule) latex_buffer.add_suffix_from_file(misc.abs_path('latex', 'end.tex')) return latex_buffer
def __init__(self, parent, datamodel, model): """Initialise AbstractDialog Arguments: parent: Master window datamodel: Main datamodel model: MeasurementItemAbstract model """ log.info('AbstractDialog - initialise') # Setup variables self.parent = parent self.data = datamodel self.selected = data.datamodel.LockState() # Derived data self.schedule = self.data.schedule self.cmbs = self.data.cmbs self.locked = self.data.get_lock_states() self.initial_selected = data.datamodel.LockState() # Private variables self.mitems = [] self.remark = '' self.itemtype = None self.itemnos = [] # Setup dialog window self.builder = Gtk.Builder() self.builder.add_from_file( misc.abs_path("interface", "abstractdialog.glade")) self.window = self.builder.get_object("dialog") self.window.set_transient_for(self.parent) self.window.set_default_size(1000, 500) self.builder.connect_signals(self) # Get required objects self.treeview_abstract = self.builder.get_object("treeview_abstract") # Text Entries self.entry_abstract_remark = self.builder.get_object( "entry_abstract_remark") # Setup measurements view self.measurements_view = MeasurementsView(self.window, self.data, self.treeview_abstract) # Connect toggled signal of measurement view to callback self.measurements_view.renderer_toggle.connect( "toggled", self.onToggleCellRendererToggle) # Load data if model is not None: if model[0] == 'MeasurementItemAbstract': self.mitems = model[1][0] self.remark = model[1][1] self.entry_abstract_remark.set_text(self.remark) self.selected = data.datamodel.LockState(self.mitems) self.initial_selected = data.datamodel.LockState(self.mitems) self.locked = self.data.get_lock_states( ) - self.initial_selected # Update GUI self.update_store()
def get_latex_buffer(self, path, schedule): latex_buffer = misc.LatexFile() latex_buffer.add_preffix_from_file( misc.abs_path('latex', 'meascompletion.tex')) # replace local variables measgroup_local_vars = {} measgroup_local_vars['$cmbcompletiondate$'] = self.date latex_buffer.replace_and_clean(measgroup_local_vars) return latex_buffer
def get_latex_buffer(self, path, schedule): latex_buffer = misc.LatexFile() latex_buffer.add_preffix_from_file( misc.abs_path('latex', 'measheading.tex')) # Setup data heading = self.remark.splitlines()[0] message = self.remark[len(heading):] # Replace local variables measheading_local_vars = {} measheading_local_vars['$cmbmeasurementheading$'] = heading measheading_local_vars['$cmbmeasurementmessage$'] = message latex_buffer.replace_and_clean(measheading_local_vars) return latex_buffer
def get_latex_buffer(self, path, schedule): latex_buffer = misc.LatexFile() latex_buffer.add_preffix_from_file( misc.abs_path('latex', 'measgroup.tex')) # Replace local variables measgroup_local_vars = {} measgroup_local_vars['$cmbmeasurementdate$'] = self.date latex_buffer.replace_and_clean(measgroup_local_vars) for count, item in enumerate(self.items): newpath = list(path) + [count] latex_buffer += item.get_latex_buffer(newpath, schedule) return latex_buffer
def __init__(self, parent, item_schedule, itemnos, captions, columntypes, render_funcs, dimensions=None): """Initialise ScheduleDialog class Arguments: parent: Parent widget (Main window) item_schedule: Agreement schedule itemnos: Itemsnos of items being meaured captions: Captions of columns columntypes: Data types of columns. Takes following values: misc.MEAS_NO: Integer misc.MEAS_L: Float misc.MEAS_DESC: String misc.MEAS_CUST: Value provided through render function render_funcs: Fucntions generating values of CUSTOM columns dimensions: List for two lists passing column widths and expand properties """ log.info('ScheduleDialog - Initialise') # Setup variables self.parent = parent self.itemnos = itemnos self.captions = captions self.columntypes = columntypes self.render_funcs = render_funcs self.item_schedule = item_schedule self.dimensions = dimensions # Save undo stack of parent self.stack_old = undo.stack() # Initialise undo/redo stack self.stack = undo.Stack() undo.setstack(self.stack) # Setup dialog window self.builder = Gtk.Builder() self.builder.add_from_file( misc.abs_path("interface", "scheduledialog.glade")) self.window = self.builder.get_object("dialog") self.window.set_transient_for(self.parent) self.window.set_default_size(1000, 500) self.builder.connect_signals(self) # Get required objects self.listbox_itemnos = self.builder.get_object("listbox_itemnos") self.tree = self.builder.get_object("treeview_schedule") # Setup schdule view for items self.schedule_view = schedule.ScheduleViewGeneric( self.parent, self.tree, self.captions, self.columntypes, self.render_funcs) if dimensions is not None: self.schedule_view.setup_column_props(*dimensions) # Setup liststore model for schedule selection from item schedule itemnos = self.item_schedule.get_itemnos() self.item_schedule_store = Gtk.ListStore(str, str, str, str) for itemno in itemnos: item = self.item_schedule[itemno] self.item_schedule_store.append([ item.itemno, item.extended_description_limited, item.unit, item.reference ]) # Setup remarks row row = Gtk.ListBoxRow() hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) label = Gtk.Label("Remarks:") entry = Gtk.Entry() # Pack row row.add(hbox) hbox.pack_start(label, False, True, 3) hbox.pack_start(entry, True, True, 3) # Set additional properties label.props.width_request = 50 # Add to list box self.listbox_itemnos.add(row) self.remark_cell = entry self.item_buttons = [] self.item_remarks_cell = [] for itemno, index in zip(self.itemnos, list(range(len(self.itemnos)))): # Get items in row row = Gtk.ListBoxRow() hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) entry = Gtk.Entry() button_clear = Gtk.Button(stock=Gtk.STOCK_CLEAR) button_item = Gtk.Button.new_with_label("None") # Pack row row.add(hbox) hbox.pack_start(entry, False, True, 3) hbox.pack_start(button_item, True, True, 3) hbox.pack_start(button_clear, False, True, 0) # Set additional properties entry.props.width_request = 50 button_clear.connect("clicked", self.onClearButtonPressed, button_item, index) button_item.connect("clicked", self.OnItemSelectClicked, index) # Add to list box self.listbox_itemnos.add(row) # Save variables self.item_buttons.append(button_item) self.item_remarks_cell.append(entry)
def __init__(self, parent, data_object, bill_data, this_bill=None): """Initialises bill dialog Arguments: parent: Master window data_object: Main datamodel bill_data: Bill model being edited this_bill: Row to bill being edited in main datamodel """ log.info('BillDialog - initialise') # Setup variables self.parent = parent self.data = data_object self.billdata = data.bill.BillData() self.billdata.set_model(copy.deepcopy(bill_data)) self.this_bill = this_bill # if in edit mode, use this to filter out this bill entries # Derived data self.schedule = self.data.schedule self.bills = self.data.bills self.cmbs = self.data.cmbs self.selected = data.datamodel.LockState(self.billdata.mitems) self.locked = self.data.get_lock_states() - self.selected # Setup dialog window self.builder = Gtk.Builder() self.builder.add_from_file( misc.abs_path("interface", "billdialog.glade")) self.window = self.builder.get_object("dialog") self.window.set_default_size(1000, 500) self.window.set_transient_for(self.parent) self.builder.connect_signals(self) # Get required objects self.treeview_bill = self.builder.get_object("treeview_bill") self.liststore_previous_bill = self.builder.get_object( "liststore_previous_bill") self.combobox_bill_last_bill = self.builder.get_object( "combobox_bill_last_bill") # Text Entries self.entry_bill_title = self.builder.get_object("entry_bill_title") self.entry_bill_cmbname = self.builder.get_object("entry_bill_cmbname") self.entry_bill_bill_date = self.builder.get_object( "entry_bill_bill_date") self.entry_bill_starting_page = self.builder.get_object( "entry_bill_starting_page") self.textview_bill_text = self.builder.get_object("textview_bill_text") # Setup cmb tree view self.measurements_view = measurement.MeasurementsView( self.schedule, self.data, self.treeview_bill) # Setup previous bill combo box list store self.liststore_previous_bill.append([0, 'None']) # Add nil entry for row, bill in enumerate(self.bills): if row != self.this_bill: self.liststore_previous_bill.append([row + 1, bill.get_text()]) # Connect toggled signal of measurement view to callback self.measurements_view.renderer_toggle.connect( "toggled", self.onToggleCellRendererToggle) # Load data if self.billdata.prev_bill is not None: self.combobox_bill_last_bill.set_active(self.billdata.prev_bill + 1) else: self.combobox_bill_last_bill.set_active(0) self.entry_bill_title.set_text(self.billdata.title) self.entry_bill_cmbname.set_text(self.billdata.cmb_name) self.entry_bill_bill_date.set_text(self.billdata.bill_date) self.entry_bill_starting_page.set_value(self.billdata.starting_page) self.textview_bill_text.get_buffer().set_text(self.billdata.bill_text) # Special conditions for custom bill if self.billdata.bill_type == misc.BILL_CUSTOM: self.treeview_bill.set_sensitive( False) # Deactivate measurement item entry self.combobox_bill_last_bill.set_sensitive( False) # Deactivate last bill selection # Update GUI self.update_store()