def newdbfile(self): # Use the Open dialog to get a database path newdb = fileaccess.openDialog(self.window) # Do nothing if no path is given/valid if newdb != None: # Close the old database, if it exists try: self.db.close() except: pass # Reassign the current database self.db = newdb # Update both tables with the new database information self.updateTickets() self.updateOrders() if self.firstrun == True: # Active all buttons once a database is opened self.builder.get_object("toolbutton4").set_sensitive(True) self.builder.get_object("toolbutton5").set_sensitive(True) self.builder.get_object("toolbutton6").set_sensitive(True) self.builder.get_object("toolbutton8").set_sensitive(True) self.builder.get_object("toolbutton9").set_sensitive(True) self.firstrun = False self.statusPush("Database opened successfully!") else: self.statusPush("The file you've selected is invalid. Please try another.")
def __init__(self): # use Gtk Builder to build the UI from file self.builder = Gtk.Builder() self.builder.add_from_file("reader.glade") # Connect all the events to the functions in this class self.builder.connect_signals(self) # Fetch the whole window self.window = self.builder.get_object("window1") # This value needs to be changed by the program, so fetch it too self.entry1 = self.builder.get_object("entry1") # Once everything is fetched, show the windows self.window.show_all() self.db = fileaccess.openDialog(self.window) if self.db == None: raise SystemExit(0) # To prevent multiple database reads, store the whole table in memory at the start self.tickets = self.db.read("ticket_types") print(self.db.read("user_info"))
def newdbfile(self): newdb = fileaccess.openDialog(self.window) if newdb != None: print("New File") # debug code try: self.db.close() except: pass self.db = newdb # Translate the database ticket types into a GUI list self.dbticket = self.db.read("ticket_types") self.tickets = [] # For every ticket type, label a button for it for i in range(4): self.tickets.append([self.dbticket[i][1], str(locale.currency(self.dbticket[i][2]))]) button = self.builder.get_object("button{0}".format(str(i+1))) button.set_label(self.dbticket[i][1]) # Set a tooltip description that can be set by the user button.set_tooltip_text(self.dbticket[i][3]) self.clearTable() return True else: return False