def __init__(self, parent, *args, **kwargs): Page.__init__(self, parent, *args, **kwargs) # Ensure user has proper permisissions if not self.validate(): return self.vars = struct() self.addWidgets()
def addWidgets(self): s = struct() self.vars = s s.userid = tk.StringVar() s.passwd1 = tk.StringVar() s.passwd2 = tk.StringVar() s.issuper = tk.BooleanVar() s.email = tk.StringVar() s.firstname = tk.StringVar() s.lastname = tk.StringVar() # Basic Info Frame f = ttk.Labelframe(self, text="Login Information") tk.Label(f, text="User ID:").grid(row=0, column=0, sticky="E") ttk.Entry(f, textvariable=s.userid, state=tk.DISABLED).grid(row=0, column=1, sticky="W") tk.Label(f, text="Password:"******"E") ttk.Entry(f, show="•", textvariable=s.passwd1).grid(row=1, column=1, sticky="W") tk.Label(f, text="Repeat Password:"******"E") ttk.Entry(f, show="•", textvariable=s.passwd2).grid(row=2, column=1, sticky="W") self.check = ttk.Checkbutton(f, text="Give evelated privaleges?", var=s.issuper, state=tk.DISABLED) self.check.grid(row=3, column=1, sticky="W") f.rowconfigure((0, 1, 2, 3), pad=2) f.columnconfigure((0, 1), weight=1, pad=5) f.pack(fill="x", padx=10, pady=10) # Auxillary Info Frame f = ttk.LabelFrame(self, text="Other Information") tk.Label(f, text="Student/Staff Email:").grid(row=0, column=0, sticky="E") ttk.Entry(f, textvar=s.email, width=40).grid(row=0, column=1, sticky="W") tk.Label(f, text="First Name:").grid(row=1, column=0, sticky="E") ttk.Entry(f, textvar=s.firstname).grid(row=1, column=1, sticky="W") tk.Label(f, text="Last/Organization Name:").grid(row=2, column=0, sticky="E") ttk.Entry(f, textvar=s.lastname).grid(row=2, column=1, sticky="W") f.rowconfigure((0, 1, 2, 3), pad=2) f.columnconfigure((0, 1), weight=1, pad=5) f.pack(fill="x", padx=10, pady=10) ttk.Button(self, text="Save Changes", command=self.save).pack()
def addWidgets(self): rf = tk.Frame(self) # Right Pane lf = tk.Frame(self) # Left Pane self.vars = struct() self.vars.userid = "{}, {} ({})".format(self.user.lastname, self.user.firstname, self.uid) self.vars.numPrints = tk.IntVar(value=0) self.vars.cost = tk.StringVar(value="${:.2f}".format(0)) ttk.Label(lf, text="User: "******"E") ttk.Label(lf, text=self.vars.userid).grid(row=0, column=1, sticky="W") ttk.Label(lf, text="# Prints: ").grid(row=1, column=0, sticky="E") ttk.Entry(lf, textvar=self.vars.numPrints, state="disabled").grid(row=1, column=1, sticky="W") ttk.Label(lf, text="Total:").grid(row=2, column=0, sticky="E") ttk.Entry(lf, textvar=self.vars.cost, state="disabled").grid(row=2, column=1, sticky="W") ttk.Button(lf, text="Create Invoice", command=self.addInvoice).grid(row=3, column=0, columnspan=2) ttk.Button(lf, text="Cancel", command=self.cancel).grid(row=4, column=0, columnspan=2) lf.pack(side="left", fill="y", expand="false") # Unadded Prints self.tablePrints = TableView( rf, columns=["Print ID", "Date", "Length", "Duration"]) self.tablePrints.pack(side="top", fill="x", expand="true", padx=2, pady=2) f = tk.Frame(rf) ttk.Button(f, text="Add Prints to Invoice", command=self.add).pack(side="right", padx=2) ttk.Button(f, text="Remove Print", command=self.remove).pack(side="right") ttk.Button(f, text="Refund Print", command=self.addRefund).pack(side="right") f.pack(side="top", fill="x", expand="true") self.tableAdded = TableView( rf, columns=["Mode", "Print ID", "Date", "Cost"]) self.tableAdded.pack(side="bottom", fill="x", expand="true", padx=2, pady=2) rf.pack(side="right", fill="both", expand="true") # Events self.tablePrints.bind("<Double-1>", lambda e: self.add) self.tableAdded.bind("<Double-1>", lambda e: self.remove) self.refresh()
def __init__(self, parent, user, *args, **kwargs): tk.Toplevel.__init__(self, parent, *args, **kwargs) self.client = parent.client self.parent = parent self.user = user # Set up filtering self.filter = struct() self.filter.invid = tk.StringVar() self.filter.printid = tk.StringVar() self.filter.dateMin = tk.StringVar() self.filter.dateMax = tk.StringVar() self.filter.costMin = tk.StringVar() self.filter.costMax = tk.StringVar() # Add Widgets self.addWidgets() self.filt() # Store selected prints for export self.selection = []
def __init__(self, parent, *args, **kwargs): Page.__init__(self, parent, *args, **kwargs) # Load Invoices self.invs = self.client.invoice_get() # Prapare GUI variables for data aquisition self.vars = struct() v = self.vars v.userid = tk.StringVar() v.dateMin = tk.StringVar() v.dateMax = tk.StringVar() # Set up GUI self.addWidgets() self.refreshTree() self.tree.sort(0) # Load Config self.conf = ConfigParser() self.conf.read("client.ini")
def __init__(self, parent, *args, **kwargs): Page.__init__(self, parent, *args, **kwargs) # Get login before opening screen. We ask for login so that we can display only prints # belonging to the actual user status, code, self.userid, self.passwd = UserVerify.verifyLogin(self) self.issuper = self.client.user_issuper(self.userid, self.passwd) if not status: if code == UserVerify.BAD_LOGIN: msg.showerror( "Bad Login", "Your login info is incorrect. Please try again.") self.abort = True return self.vars = struct() self.vars.userid = tk.StringVar(value=self.userid) self.vars.printid = tk.StringVar() self.vars.completion = tk.DoubleVar() self.addWidgets() self.refresh()
def __init__(self, parent, *args, **kwargs): Page.__init__(self, parent, *args, **kwargs) auth_userid, auth_passwd = UserVerify.getLogin(self) if not self.client.user_get(userid=auth_userid): messagebox.showerror("Authentication Error", "No login exists under that username.") return if not self.client.user_verify(auth_userid, auth_passwd): messagebox.showerror("Autherntication Error", "The username/password is invalid.") return if not self.client.user_issuper(auth_userid, auth_passwd): messagebox.showerror( "Authentication Error", "You do not have permission to access this page.") return self.auth_userid = auth_userid self.auth_passwd = auth_passwd self.vars = struct() # Container for tk input variables self.addWidgets()
def __init__(self, parent, printjob, *args, **kwargs): Page.__init__(self, parent, *args, **kwargs) # Get Verification. Only admit people who are moderators or who already own the print. status, code, userid, passwd = UserVerify.verifyLogin( self, target=printjob.userid) if not status: if code == UserVerify.BAD_LOGIN: msg.showerror( "Bad Login", "Your login info is incorrect. Please try again.") elif code == UserVerify.WRONG_USER: msg.showerror( "Bad Login", "You don't have permission to access this print.") self.abort = True return self.rates = self.client.rate_get() self.printers = self.client.printer_get() # Create Tk Variables self.vars = struct() v = self.vars v.userid = tk.StringVar(value=printjob.userid) v.notPayer = tk.IntVar(value=printjob.paidBy != printjob.userid) v.payer = tk.StringVar(value=printjob.paidBy) v.length = tk.StringVar(value=printjob.length) v.durationHr = tk.StringVar(value=printjob.duration // 60) v.durationMin = tk.StringVar(value=printjob.duration % 60) v.rate = tk.StringVar(value=printjob.rate.name) v.printer = tk.StringVar(value=printjob.printer) v.finished = tk.IntVar(value=printjob.finished) self.printjob = printjob self.addWidgets()
def addWidgets(self): s = struct() self.vars = s s.userid = tk.StringVar() s.passwd1 = tk.StringVar() s.passwd2 = tk.StringVar() s.issuper = tk.BooleanVar() s.email = tk.StringVar() s.firstname = tk.StringVar() s.lastname = tk.StringVar() s.auth_userid = tk.StringVar() s.auth_passwd = tk.StringVar() # Basic Info Frame f = ttk.Labelframe(self, text="Login Information") tk.Label(f, text="User ID:").grid(row=0, column=0, sticky="E") ttk.Entry(f, textvariable=s.userid).grid(row=0, column=1, sticky="W") tk.Label(f, text="Password:"******"E") ttk.Entry(f, show="•", textvariable=s.passwd1).grid(row=1, column=1, sticky="W") tk.Label(f, text="Repeat Password:"******"E") ttk.Entry(f, show="•", textvariable=s.passwd2).grid(row=2, column=1, sticky="W") ttk.Checkbutton(f, text="Give evelated privaleges?", var=s.issuper).grid(row=3, column=1, sticky="W") f.rowconfigure((0, 1, 2, 3), pad=2) f.columnconfigure((0, 1), weight=1, pad=5) f.pack(fill="x", padx=10, pady=10) # Authotization Frame f = ttk.Labelframe(self, text="Authorization") tk.Label(f, text="Please have a moderator fill this section.").grid( row=0, column=0, columnspan=2) tk.Label(f, text="Mod User ID:").grid(row=1, column=0, sticky="E") ttk.Entry(f, textvar=s.auth_userid).grid(row=1, column=1, sticky="W") tk.Label(f, text="Mod Password:"******"E") ttk.Entry(f, show="•", textvar=s.auth_passwd).grid(row=2, column=1, sticky="W") f.rowconfigure((0, 1, 2, 3), pad=2) f.columnconfigure((0, 1), weight=1, pad=5) f.pack(fill="x", padx=10, pady=10) # Auxillary Info Frame f = ttk.LabelFrame(self, text="Other Information") tk.Label(f, text="Student/Staff Email:").grid(row=0, column=0, sticky="E") ttk.Entry(f, textvar=s.email, width=40).grid(row=0, column=1, sticky="W") tk.Label(f, text="First Name:").grid(row=1, column=0, sticky="E") ttk.Entry(f, textvar=s.firstname).grid(row=1, column=1, sticky="W") tk.Label(f, text="Last/Organization Name:").grid(row=2, column=0, sticky="E") ttk.Entry(f, textvar=s.lastname).grid(row=2, column=1, sticky="W") f.rowconfigure((0, 1, 2, 3), pad=2) f.columnconfigure((0, 1), weight=1, pad=5) f.pack(fill="x", padx=10, pady=10) ttk.Button(self, text="Create User", command=self.addUser).pack()
def __init__(self, parent, *args, **kwargs): Page.__init__(self, parent, *args, **kwargs) self.vars = struct() self.addWidgets()
def addWidgets(self): self.vars = struct() v = self.vars v.f_printid = tk.StringVar() v.f_rate = tk.StringVar(value="All") v.f_useridPrint = tk.StringVar() v.f_useridPay = tk.StringVar() v.f_lengthMin = tk.DoubleVar(value=0.0) v.f_lengthMax = tk.DoubleVar(value=999.0) v.f_durationMin = tk.IntVar(value=0) v.f_durationMax = tk.IntVar(value=999) v.f_dateMin = tk.StringVar() v.f_dateMax = tk.StringVar() v.f_finished = tk.StringVar(value="Both") self.rateDict = dict() for r in self.rates: self.rateDict[r.name] = r # Add Buttons f = tk.Frame(self) ttk.Button(f, text="Open Print", width=20, command=self.edit).pack(side="top") ttk.Button(f, text="Delete Print", width=20, command=self.delete).pack(side="top") ttk.Button(f, text="Mark as Finished", width=20, command=self.finish).pack(side="top") ttk.Button(f, text="Filter", width=20, command=self.filt).pack(side="bottom") f.pack(side="right", fill="y") # Add List f = tk.Frame(self) columns = ("printid", "userid", "date", "cost", "rate", "printer", "length", "duration", "finished") '''self.tree = ttk.Treeview(f, columns=columns, show="headings", selectmode="browse") self.tree.column("printid", width=150, anchor="w") self.tree.heading("printid", text="Print ID", command=lambda: self.sort(0)) self.tree.column("userid", width=100, anchor="w") self.tree.heading("userid", text="User ID", command=lambda: self.sort(1)) self.tree.column("date", width=150, anchor="w") self.tree.heading("date", text="Date Logged", command=lambda: self.sort(2)) self.tree.column("cost", width=100, anchor="w") self.tree.heading("cost", text="Cost", command=lambda: self.sort(3)) self.tree.column("rate", width=100, anchor="w") self.tree.heading("rate", text="Pricing Rate", command=lambda: self.sort(4)) self.tree.column("printer", width=100, anchor="w") self.tree.heading("printer", text="Printer", command=lambda: self.sort(5)) self.tree.column("length", width=100, anchor="w") self.tree.heading("length", text="Length", command=lambda: self.sort(6)) self.tree.column("duration", width=100, anchor="w") self.tree.heading("duration", text="Duration", command=lambda: self.sort(7)) self.tree.column("finished", width=100, anchor="w") self.tree.heading("finished", text="Finished?", command=lambda: self.sort(8))''' self.tree = TableView(f, columns=columns, selectmode="browse") self.tree.pack(fill="both", expand="true") hsb = ttk.Scrollbar(f, orient="horizontal", command=self.tree.xview) hsb.pack(side="bottom", fill="x") self.tree.configure(xscrollcommand=hsb.set) f.pack(fill="both", expand="true") # Filtering f = tk.Frame(self) f.columnconfigure((0, 1, 2, 3), weight=1, pad=5) f.rowconfigure((0, 1, 2), weight=1, pad=5) tk.Label(f, text="Print ID").grid(row=0, column=0, sticky="W") tk.Label(f, text="User ID (printer)").grid(row=1, column=0, sticky="W") tk.Label(f, text="User ID (payer)").grid(row=2, column=0, sticky="W") ttk.Entry(f, textvar=v.f_printid).grid(row=0, column=1, sticky="EW") ttk.Entry(f, textvar=v.f_useridPrint).grid(row=1, column=1, sticky="EW") ttk.Entry(f, textvar=v.f_useridPay).grid(row=2, column=1, sticky="EW") tk.Label(f, text="Length (Min/Max)").grid(row=0, column=2, sticky="W") tk.Label(f, text="Duration (Min/Max)").grid(row=1, column=2, sticky="W") tk.Label(f, text="Date (Min/Max)").grid(row=2, column=2, sticky="W") ff = tk.Frame(f) ttk.Entry(ff, textvar=v.f_lengthMin, width=10).pack(side="left", fill="x") ttk.Entry(ff, textvar=v.f_lengthMax, width=10).pack(side="right", fill="x") ff.grid(row=0, column=3, sticky="EW") ff = tk.Frame(f) ttk.Entry(ff, textvar=v.f_durationMin, width=10).pack(side="left", fill="x") ttk.Entry(ff, textvar=v.f_durationMax, width=10).pack(side="right", fill="x") ff.grid(row=1, column=3, sticky="EW") ff = tk.Frame(f) ttk.Entry(ff, textvar=v.f_dateMin, width=10).pack(side="left", fill="x") ttk.Entry(ff, textvar=v.f_dateMax, width=10).pack(side="right", fill="x") ff.grid(row=2, column=3, sticky="EW") f.pack(side="bottom", fill="x") rateOpts = ["All"] + [r.name for r in self.rates] finOpts = ["All", "Yes", "No"] tk.Label(f, text="Rate").grid(row=3, column=0, sticky="W") tk.Label(f, text="Finished?").grid(row=3, column=2, sticky="W") ttk.Combobox(f, textvar=v.f_rate, values=rateOpts, state="readonly").grid(row=3, column=1, sticky="EW") ttk.Combobox(f, textvar=v.f_finished, values=finOpts, state="readonly").grid(row=3, column=3, sticky="EW")
def addWidgets(self): self.vars = struct() v = self.vars v.userid = tk.StringVar() v.passwd = tk.StringVar() v.isPayer = tk.IntVar() v.payer = tk.StringVar() v.length = tk.StringVar() v.durationHr = tk.StringVar() v.durationMin = tk.StringVar() v.rate = tk.StringVar() v.printer = tk.StringVar() rownum = rn() r = rownum.row n = rownum.new content = tk.Frame(self, width=500) # User and Billing Info f = ttk.Labelframe(content, text="User Info", width=500) tk.Label(f, text="User ID").grid(row=r(), column=0, sticky="E") ttk.Entry(f, textvar=v.userid).grid(row=n(), column=1, sticky="EW") tk.Label(f, text="Password").grid(row=r(), column=0, sticky="E") ttk.Entry(f, show="•", textvar=v.passwd).grid(row=n(), column=1, sticky="EW") ttk.Checkbutton(f, text="Is a different user paying for this print?", variable=v.isPayer, command=self.enablePayerEntry).grid(row=n(), column=0, columnspan=2) tk.Label(f, text="User ID").grid(row=r(), column=0, sticky="E") self.payeeEntry = ttk.Entry(f, textvar=v.payer) self.payeeEntry.grid(row=n(), column=1, sticky="EW") f.rowconfigure([i for i in range(f.grid_size()[1])], pad=2) f.columnconfigure([0, 1], weight=1, pad=5) f.grid(row=0, column=0, sticky="EW") # Print Info f = ttk.Labelframe(content, text="Print Info") rownum.reset() tk.Label(f, text="Length of print (m):").grid(row=r(), column=0, sticky="E") ttk.Entry(f, textvar=v.length).grid(row=n(), column=1, sticky="EW") tk.Label(f, text="Duration of print:").grid(row=r(), column=0, sticky="E") _f = tk.Frame(f) ttk.Entry(_f, textvar=v.durationHr, width=5).grid(row=0, column=0, sticky="EW") tk.Label(_f, text="hr ").grid(row=0, column=1, sticky="W") ttk.Entry(_f, textvar=v.durationMin, width=5).grid(row=0, column=2, sticky="EW") tk.Label(_f, text="min ").grid(row=0, column=4, sticky="W") _f.columnconfigure((0, 1, 2), weight=1) _f.grid(row=n(), column=1, sticky="W") tk.Label(f, text="Printer:").grid(row=r(), column=0, sticky="E") ttk.Combobox(f, textvariable=v.printer, values=[p for p in self.printers]).grid(row=n(), column=1, sticky="EW") tk.Label(f, text="Print Rate:").grid(row=r(), column=0, sticky="E") ttk.Combobox(f, textvariable=v.rate, values=[r.rateid for r in self.rates]).grid(row=n(), column=1, sticky="EW") tk.Label(f, text="Notes (optional):").grid(row=n(), column=0, sticky="W") self.notesWid = tk.Text(f, width=50, height=5) self.notesWid.grid(row=n(), column=0, columnspan=2, sticky="EW") f.rowconfigure([i for i in range(f.grid_size()[1])], pad=2) f.columnconfigure([0, 1], weight=1, pad=5) f.grid(row=1, column=0, sticky="EW") f = tk.Frame(content) ttk.Button(f, text="Submit", command=self.submit, underline=0).grid(row=0, column=1, sticky="EW") ttk.Button(f, text="Cancel", command=self.cancel, underline=0).grid(row=0, column=0, sticky="EW") f.columnconfigure((0, 1), weight=1, pad=3) f.grid(row=2, column=0, sticky="EW") content.columnconfigure(0, weight=1) content.pack(fill="y", expand=True) self.bind("<Control-s>", lambda e: self.submit) self.bind("<Control-c>", lambda e: self.cancel)