def addCharacter(self, event): name = self.sNam.GetValue() #Getting the UI out for processing gen = self.sGen.GetValue() age = self.sAge.GetValue() occ = self.sOcc.GetValue() #Checking for blank input if (name == '') or (gen == '') or (age == ''): #Dialogue Box for user input dlg = wx.MessageDialog(None, 'Some Character details are missing', 'Enter values for all text boxes', 'Details missing', wx.OK) dlg.ShowModal() dlg.Destroy() db_program.newCharacter(name, gen, age, occ) print db_program.viewAll() #Clear UI when done self.sNam.Clear() self.sGen.Clear() self.sAge.SetValue(0) self.sOcc.Clear() # Add data to the list control self.fillListCtrl()
def addCharacter(self, event): name = self.sName.GetValue() gen = self.sGen.GetValue() age = self.sAge.GetValue() occ = self.sOcc.GetValue() # Checking if variables have a value if (name == '') or (gen == '') or (age == '') or (occ == ''): # Alert user that a variable is empty dlg = wx.MessageDialog(None, \ 'Some character details are missing. Enter values in each text box.', \ 'Missing Details', wx.OK) dlg.ShowModal() dlg.Destroy() return False # Adding character to database db_program.newCharacter(name, gen, age, occ) print db_program.viewAll() # Empty text boxes when finished. self.sName.Clear() self.sGen.Clear() self.sOcc.Clear() self.sAge.SetValue(0) # Update list control self.fillListCtrl()
def addCharacter(self, event): title = self.sTitle.GetValue() body = self.sBody.GetValue() paragraph = self.sParagraph.GetValue() footer = self.sFooter.GetValue() # Checking if variables have a value if (title == '') or (body == '') or (paragraph == '') or (footer == ''): # Alert user that a variable is empty dlg = wx.MessageDialog(None, \ 'Some HTML details are missing. Enter values in each text box.', \ 'Missing Details', wx.OK) dlg.ShowModal() dlg.Destroy() return False # Adding character to database db_program.newHTML(title, body, paragraph, footer) print db_program.viewAll() # Empty text boxes when finished. self.sTitle.Clear() self.sBody.Clear() self.sParagraph.Clear() self.sFooter.Clear() # Update list control self.fillListCtrl()
def addCharacter(self, event): name = self.sName.GetValue() gen = self.sGen.GetValue() age = self.sAge.GetValue() occ = self.sOcc.GetValue() # Adding character to database db_program.newCharacter(name, gen, age, occ) print db_program.viewAll()
def addCharacter(self, event): name = self.sName.GetValue() gen = self.sGen.GetValue() age = self.sAge.GetValue() occ = self.sOcc.GetValue() # Checking if variables have a value if (name == '') or (gen == '') or (age == '') or (occ == ''): print 'At least one variable is empty' return False # Adding character to database db_program.newCharacter(name, gen, age, occ) print db_program.viewAll()
def fillListCtrl(self): allData = db_program.viewAll() #delete old data before adding data self.listCtrl.DeleteAllItems() for row in allData: #loop through and append data self.listCtrl.Append(row)
def fillListCtrl(self): # Get data from the database allData = db_program.viewAll() # Append data to the table for row in allData: # Loop though and append data listCtrl.Append(row)
def fillListCtrl(self): # Get data from the database self.allData = db_program.viewAll() # Delete old data before adding new data self.listCtrl.DeleteAllItems() # Append data to the table for row in self.allData: # Loop though and append data self.listCtrl.Append(row)
def fillListCtrl(self): # Get data from the database allData = db_program.viewAll() # Delete old data before adding new data self.listCtrl.DeleteAllItems() # Append data to the table for row in allData: # Loop though and append data self.listCtrl.Append(row)
def updateTreeView(self): # Get data from the database self.allData = db_program.viewAll() # Delete old data before adding new data for i in self.htmlTree.get_children(): self.htmlTree.delete(i) # Append data to the table html_list= db_program.viewAll() for item in html_list: self.htmlTree.insert('', 'end', values=item) # adjust column's width if necessary to fit each value for ix, val in enumerate(item): col_w = tkFont.Font().measure(val) #Clean out the update text boxes self.update_title.delete(0, END) self.update_body.delete(0, END) self.update_paragraph.delete(0, END) self.update_footer.delete(0, END)
def fillListCnt(self): self.listCnt.DeleteAllItems() allData = db_program.viewAll() for row in allData: self.listCnt.Append(row)
def fillListCtrl(self): # Get data from the database allData = db_program.viewAll()
def __init__(self, master): master.title('Build A HTML Page') #master.resizable(False, False) self.style = ttk.Style() #Input frame self.frame_input = ttk.LabelFrame(master, text="Create New HTML Page") self.frame_input.grid(row=0, column = 0, sticky='nw', pady=40) ttk.Label(self.frame_input, text = 'Title:').grid(row = 0, column = 0, padx = 5, pady=8,sticky = 'sw') ttk.Label(self.frame_input, text = 'Body:').grid(row = 1, column = 0, padx = 5, pady=8,sticky = 'sw') ttk.Label(self.frame_input, text = 'Paragraph:').grid(row = 2, column = 0, padx = 5, pady=8,sticky = 'sw') ttk.Label(self.frame_input, text = 'Footer:').grid(row = 3, column = 0, padx = 5, pady=8,sticky = 'sw') self.entry_title = ttk.Entry(self.frame_input, width = 24, font = ('Arial', 10)) self.entry_body = ttk.Entry(self.frame_input, width = 24, font = ('Arial', 10)) self.entry_paragraph = ttk.Entry(self.frame_input, width = 24, font = ('Arial', 10)) self.entry_footer = ttk.Entry(self.frame_input, width = 24, font = ('Arial', 10)) self.entry_title.grid(row = 0, column = 2, padx = 5, pady=8) self.entry_body.grid(row = 1, column = 2,pady=8, padx = 5) self.entry_paragraph.grid(row = 2, column = 2, pady=8,padx = 5) self.entry_footer.grid(row = 3, column = 2, pady=8,padx = 5) ttk.Button(self.frame_input, text = 'Create HTML', command = self.submit).grid(row = 4, column = 0, columnspan=2, padx = 5, pady = 5, sticky = 'w') #Update frame self.frame_update = ttk.LabelFrame(master, text="Update HTML Page") self.frame_update.grid(row=1, column = 0, sticky='nw', pady=40) ttk.Label(self.frame_update, text = 'Title:').grid(row = 0, column = 0, padx = 5, pady=8, sticky = 'sw') ttk.Label(self.frame_update, text = 'Body:').grid(row = 1, column = 0, padx = 5, pady=8, sticky = 'sw') ttk.Label(self.frame_update, text = 'Paragraph:').grid(row = 2, column = 0, padx = 5, pady=8, sticky = 'sw') ttk.Label(self.frame_update, text = 'Footer:').grid(row = 3, column = 0, padx = 5, pady=8, sticky = 'sw') self.update_title = ttk.Entry(self.frame_update, width = 24, font = ('Arial', 10)) self.update_body = ttk.Entry(self.frame_update, width = 24, font = ('Arial', 10)) self.update_paragraph = ttk.Entry(self.frame_update, width = 24, font = ('Arial', 10)) self.update_footer = ttk.Entry(self.frame_update, width = 24, font = ('Arial', 10)) self.update_title.grid(row = 0, column = 1, padx = 5) self.update_body.grid(row = 1, column = 1, padx = 5) self.update_paragraph.grid(row = 2, column = 1, padx = 5) self.update_footer.grid(row = 3, column = 1, padx = 5) ttk.Button(self.frame_update, text = 'Update HTML', command = self.updateHTML).grid(row = 4, column = 0, padx = 5, pady = 5) ttk.Button(self.frame_update, text = 'View HTML', command = self.viewHTML).grid(row = 4, column = 1, padx = 5, pady = 5) #HTML List frame self.frame_list_html = ttk.LabelFrame(master, text="List HTML Pages") self.frame_list_html.grid(row=0, column = 1, rowspan=4, sticky='ne', padx = 20, pady=40) self.htmlTree = ttk.Treeview(columns=html_header, show="headings") # create a treeview with dual scrollbars self.htmlTree = ttk.Treeview(columns=html_header, show="headings") vsb = ttk.Scrollbar(orient="vertical", command=self.htmlTree.yview) hsb = ttk.Scrollbar(orient="horizontal", command=self.htmlTree.xview) self.htmlTree.configure(yscrollcommand=vsb.set, xscrollcommand=hsb.set) self.htmlTree.grid(column=3, row=0, sticky='nsew', in_=self.frame_list_html) vsb.grid(column=4, row=0, sticky='ns', in_=self.frame_list_html) hsb.grid(column=3, row=1, sticky='ew', in_=self.frame_list_html) self.frame_list_html.grid_columnconfigure(3, weight=1) self.frame_list_html.grid_rowconfigure(3, weight=1) for col in html_header: self.htmlTree.heading(col, text=col.title(), command=lambda c=col: sortby(self.htmlTree, c, 0)) # adjust the column's width to the header string self.htmlTree.column(col, width=tkFont.Font().measure(col.title())) # Get data from the database html_list= db_program.viewAll() print (html_list) for item in html_list: print (item) self.htmlTree.insert('', 'end', values=item) # adjust column's width if necessary to fit each value for ix, val in enumerate(item): col_w = tkFont.Font().measure(val) if self.htmlTree.column(html_header[ix],width=None)<col_w: self.htmlTree.column(html_header[ix], width=col_w) self.htmlTree.bind("<ButtonRelease-1>", self.selection) ttk.Button(self.frame_list_html, text = 'Delete', command = self.onDelete).grid(row = 5, column = 0, columnspan=4, padx = 5, pady = 8)