Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Python how do i get numberOfItemsHired to accept only 1-500 items, and if not 1-500 display an error message

dumps41

New Coder
how do i get numberOfItemsHired to accept only 1-500 items, and if not 1-500 display an error message?
This is my code, I've tried
Python:
if not int(entry_numberOfItemsHired.get()) >= 1 or int(entry_numberOfItemsHired.get()) <= 500:
and I've also tried using:
Python:
if len(range(int((entry_numberOfItemsHired.get())))  in range (1,500):`
but this does not work as len doesn't work properly with int values. I also tried converting entry_numberOfItemsHired.get() into int before performing the code but this has not worked either.

Python:
from tkinter import*
import tkinter as tk

def quit():
    main_window.destroy()

def print_details():
    global counter
    counter= 0
    Label(main_window, text= "Row").grid(column= 0, row= 7)
    Label(main_window, text= "Customer Name").grid(column= 1, row= 7)
    Label(main_window, text= "Receipt Number").grid(column= 2, row= 7)
    Label(main_window, text= "Item Hired").grid(column= 3, row= 7)
    Label(main_window, text= "Number of Item Hired").grid(column= 4, row= 7)
    ROWS_ABOVE= 8

    while counter < number['total_entries']:
        Label(main_window, text= counter).grid(column= 0, row= counter + ROWS_ABOVE)
        Label(main_window, text= (hireDetails[counter][0])).grid(column= 1, row= counter + ROWS_ABOVE)
        Label(main_window, text= (hireDetails[counter][1])).grid(column= 2, row= counter + ROWS_ABOVE)
        Label(main_window, text= (hireDetails[counter][2])).grid(column= 3, row= counter + ROWS_ABOVE)
        Label(main_window, text= (hireDetails[counter][3])).grid(column= 4, row= counter + ROWS_ABOVE)
        counter += 1
        number['counter']= counter

       

def check_validity():
    global items
    if (entry_customer_name.get().isalpha()) and (entry_numberOfItemsHired.get().isnumeric())and int(entry_receipt_number.get().isnumeric()) != 0:
        if(range(int(entry_receipt_number.get()))) in range (1,99999999):
            numberOfItems= int(entry_numberOfItemsHired.get())
            minimum_item= 1
            maximum_item= 500
            if(minimum_item <= (numberOfItems)<= maximum_item) == True:
                items= ["Spoons", "Forks" , "Knives" , "Tables" , "Chairs" , "Cater Dishes"]
                if (entry_itemHired.get()) in items:
                    return True
                    append_details ()
                    Label(main_window, text= "Customer Name: ").grid(column= 0, row= 1)
                    Label(main_window, text= "Receipt No.: ").grid(column= 0, row= 2)
                    Label(main_window, text= "Item Hired: ").grid(column= 0, row= 3)
                    Label(main_window, text= "No. of Items Hired: ").grid(column= 0, row= 4)
                    Label(main_window, text= "                                                           ").grid(column= 2, row= 1, sticky= "W")
                    Label(main_window, text= "                                                           ").grid(column= 2, row= 2, sticky= "W")
                    Label(main_window, text= "                                                           ").grid(column= 2, row= 3, sticky= "W")
                    Label(main_window, text= "                                                           ").grid(column= 2, row= 4, sticky= "W")
               
    else:
        if len(entry_customer_name.get()) == 0:
            Label(main_window, text= "Enter Customer Name. No numbers allowed.", bg= 'red').grid(column= 2, row= 1, sticky= "W")
        else:
            Label(main_window, text= "                                                           ").grid(column= 2, row= 1, sticky= "W")
            if not(entry_customer_name.get().isalpha()):
                Label(main_window, text= "No numbers allowed.", bg= 'red').grid(column= 2, row= 1, sticky= "W")

        if len(entry_receipt_number.get()) == 0:
            Label(main_window, text= "Receipt Number is invalid.", bg= 'red').grid(column= 2, row= 2, sticky= "W")
        else:
            Label(main_window, text= "                                                           ").grid(column= 2, row= 2, sticky= "W")
            if not(entry_receipt_number.get().isnumeric()):
                Label(main_window, text= "Receipt Number is invalid. Use digits.", bg= 'red').grid(column= 2, row= 2, sticky= "W")
            elif len(range(int(entry_receipt_number.get()))) not in range (1,99999999):
                Label(main_window, text= "Receipt Number is invalid. Only 8 digits needed.", bg= 'red').grid(column= 2, row= 2, sticky= "W")

        if len(entry_itemHired.get()) == 0:
            items= ["Spoons", "Forks" , "Knives" , "Tables" , "Chairs" , "Cater Dishes"]
            Label(main_window, text= "Choose Item Hired: Spoons, Forks, Knives, Tables, Chairs, Cater Dishes.", bg= 'red').grid(column= 2, row= 3, sticky= "W")
        else:
            Label(main_window, text= "                                                           ").grid(column= 2, row= 3, sticky= "W")
            if (entry_itemHired.get()) not in items:
                Label(main_window, text= "Choose Item Hired: Spoons, Forks, Knives, Tables, Chairs, Cater Dishes.", bg= 'red').grid(column= 2, row= 3, sticky= "W")
                  
        if len(entry_numberOfItemsHired.get()) == 0:
            Label(main_window, text= "Only 1-500 items allowed to be hired.", bg= 'red').grid(column= 2, row= 4, sticky= "W")
            return False
       
        if (entry_numberOfItemsHired.get().isalpha()):
            Label(main_window, text= "Use Numbers. Only 1-500 items allowed to be hired.", bg= 'red').grid(column= 2, row= 4, sticky= "W")
            return False
           
        numberOfItems= int(entry_numberOfItemsHired.get())
        minimum_item= 1
        maximum_item= 500
        if not (minimum_item<= (numberOfItems)<= maximum_item):
            Label(main_window, text= "Only 1-500 items allowed to be hired.", bg= 'red').grid(column= 2, row= 4, sticky= "W")
            return False
        else:
            Label(main_window, text= "                                                           ").grid(column= 2, row= 4, sticky= "W")
          
                   

    return True


def append_details():
    hireDetails.append([entry_customer_name.get(),entry_receipt_number.get(),entry_itemHired.get(),entry_numberOfItemsHired.get()])
    entry_customer_name.delete(0,'end')
    entry_receipt_number.delete(0,'end')
    entry_itemHired.delete(0,'end')
    entry_numberOfItemsHired.delete(0,'end')
    number ['total_entries'] += 1

def delete_row():
    del hireDetails [int(delete_details.get())-0]
    counter= number['counter']
    number['total_entries']-=1
    delete_details.delete(0,'end')
    Label(main_window, text= "                ").grid(column= 0, row= counter + 7)
    Label(main_window, text= "                ").grid(column= 1, row= counter + 7)
    Label(main_window, text= "                ").grid(column= 2, row= counter + 7)
    Label(main_window, text= "                ").grid(column= 3, row= counter + 7)
    Label(main_window, text= "                ").grid(column= 4, row= counter + 7)
    print_details()

def main():
    Button(main_window, text= "Quit", command= quit).grid(column= 4, row= 1)
    Button(main_window, text= "Print Details", command= print_details).grid(column= 4, row= 2)
    Button(main_window, text= "Append Details", command= check_validity).grid(column= 3, row= 2)
    Button(main_window, text= "Delete ", command= delete_row).grid(column= 4, row= 5)
    Label(main_window, text= "Customer Name: ").grid(column= 0, row= 1)
    Label(main_window, text= "Receipt No.: ").grid(column= 0, row= 2)
    Label(main_window, text= "Item Hired: ").grid(column= 0, row= 3)
    Label(main_window, text= "No. Of Items Hired: ").grid(column= 0, row= 4)
    Label(main_window, text= "Row No. : ").grid(column= 2 , row= 5)

    main_window.wm_title("Party Hire Shop - Julies")

    main_window.mainloop()


number= {'total_entries':0,'counter':0}
hireDetails= []
main_window= tk.Tk()
entry_customer_name= Entry(main_window)
entry_customer_name.grid(column= 1, row= 1)
entry_receipt_number= Entry(main_window)
entry_receipt_number.grid(column= 1, row= 2)
entry_itemHired= Entry(main_window)
entry_itemHired.grid(column= 1, row= 3)
entry_numberOfItemsHired= Entry(main_window)
entry_numberOfItemsHired.grid(column= 1, row=4)
delete_details= Entry(main_window)
delete_details.grid(column= 3, row= 5)


main()
 
Last edited by a moderator:
This was answered in another forum but, I will reply here as well.
You should look into learning classes as it will make things easier in the long run.
You should not do wildcard imports as they will cause many problems e.g. from tkinter import *.
This is bad practice. I'll not post what the other op said but instead use the example code I used as I took an interest in your project. The approach I would take. On a side note you should also look into storing data either in mysql, sqlite3, json or some other form of data storage. This example will reset every time the script is ran.

Python:
import tkinter as tk
from tkinter.messagebox import showerror
from tkinter import ttk

class Data:
    ''' Data class handles the insert and delete of self.data items '''
    def __init__(self):
        self.data = []


    def _add(self, data):
        ''' Method for adding to list '''
        self.data.append(data)

    def _delete(self, row):
        ''' Method for removing items from list '''
        for index, item in enumerate(self.data):
            if row == item[0]:
                self.data.pop(index)


class Window:
    ''' Window class is for presentation '''
    def __init__(self, parent):
        self.parent = parent
        parent.columnconfigure(0, weight=1)
        parent.rowconfigure(0, weight=1)
       
        # Container for holding widgets
        container = tk.Frame(parent)
        container.grid(column=0, row=0, sticky='news')
        container.grid_columnconfigure(0, weight=3, uniform='columns')
        container.grid_columnconfigure(1, weight=3, uniform='columns')

        # container for hold the widgets on the left
        left = tk.Frame(container)
        left['highlightbackground'] = '#999999'
        left['highlightcolor'] = '#999999'
        left['highlightthickness'] = 1
        left.grid(column=0, row=0, sticky='new', padx=4, pady=4)
        left.grid_columnconfigure(1, weight=3)

        # Container for holding widgets on the right
        right = tk.Frame(container)
        right['highlightbackground'] = '#999999'
        right['highlightcolor'] = '#999999'
        right['highlightthickness'] = 1
        right.grid(column=1, row=0, sticky='new')
        right.grid_columnconfigure(0, weight=3)

        # Items for the labels
        items = ('Customer Name', 'Receipt No.:', 'Item:', 'Amount:')

        # Create the labels
        for index, item in enumerate(items):
            label = tk.Label(left, text=item, font=(None, 11, 'bold'), anchor='w')
            label.grid(column=0, row=index, sticky='new', padx=4, pady=4)

        # Create the entry fields
        self.entries = []
        for index, entry in enumerate(items):
            self.entries.append(tk.Entry(left))
            self.entries[index].grid(column=1, row=index, sticky='new', padx=4, pady=4)

        # Create a treeview
        columns = ('Row', 'Customer', 'Receipt No.', 'Item', 'Amount')
        self.tree = ttk.Treeview(right, columns=columns, show='headings', selectmode='browse')
        for column in columns:
            self.tree.heading(column, text=column)

        for column in columns:
            self.tree.column(column, stretch='no', width=130)
        self.tree.grid(column=0, row=0, sticky='news', padx=4, pady=4)

        # Container for the buttons
        btnframe = tk.Frame(container)
        btnframe['highlightbackground'] = '#999999'
        btnframe['highlightcolor'] = '#999999'
        btnframe['highlightthickness'] = 1
        btnframe.grid(column=0, columnspan=2, row=5, sticky='new', padx=4, pady=8)
        btnframe.grid_columnconfigure(1, weight=3)
       
        # Create the buttons
        self.addbtn = tk.Button(btnframe, text='Add', bg='skyblue', cursor='hand2', )
        self.addbtn.grid(column=0, row=0, sticky='news', padx=4, pady=4)
        self.addbtn.bind('<Enter>', self.e_add)

        self.delbtn = tk.Button(btnframe, text='Delete', bg='orange', cursor='hand2')
        self.delbtn.grid(column=1, row=0, sticky='e', padx=4, pady=4)
        self.delbtn.bind('<Enter>', self.e_del)

        self.exitbtn = tk.Button(btnframe, text='Exit', bg='tomato', cursor='hand2', command=parent.destroy)
        self.exitbtn.grid(column=2, row=0, sticky='e', padx=4,pady=4)
        self.exitbtn.bind('<Enter>', self.e_enter)

    # Methods for giving a hover effect
    def e_enter(self, event):
        self.exitbtn.configure(activebackground='red')

    def e_del(self, event):
        self.delbtn.configure(activebackground='orangered')

    def e_add(self, event):
        self.addbtn.configure(activebackground='powderblue')
       

class Controller:
    ''' Controller class handles communications between window and data class '''
    def __init__(self, data, window):
        self.data = data
        self.window = window

        # Button commands
        self.window.addbtn.configure(command=self._add)
        self.window.delbtn.configure(command=self._delete)

        # So the treeview is loaded with data if any
        self.refresh()

    def _delete(self):
        ''' Method for deleting items from list '''
        try:
            item = self.window.tree.focus()
            row = self.window.tree.item(item)['values'][0]
            self.data._delete(int(row))
            self.refresh()
        except:
            pass

    def _add(self):
        ''' Method for adding items to the list '''
        entries = self.window.entries
       
        customer = entries[0].get()
        receipt = entries[1].get()
        item = entries[2].get()
        amount = entries[3].get()

        # A little error checking
        error = 0
        messages = []

        items = ['spoons', 'forks', 'knives', 'tables', 'chairs', 'cater dishes']

        if not customer:
            messages.append('Customer name is required.')
            error += 1

        if not receipt.isnumeric():
            messages.append('Receipt no. needs to be digits')
            error += 1

        if item.lower() not in items:
            messages.append(f'Item has to be one of: {", ".join(items)}')
            error += 1


        if not amount.isnumeric():
            messages.append('Amount must be digits')
            error += 1

        elif int(amount) < 1 or int(amount) > 500:
            messages.append('Amount needs to be between 1 and 500')
            error += 1

        # If there are errors display using messagebox
        if error > 0:
            field = 'These fields need' if error > 1 else 'This field needs'
            showerror('Error!', f'{field} to be corrected:\n{"\n".join(messages)}')
           
        # Everything is ok add data to the list
        else:
            row = len(self.data.data)+1
            self.data._add((row, customer, receipt, item, amount))
           
            for index, field in enumerate(self.window.entries):
                self.window.entries[index].delete(0, tk.END)

            self.refresh()
       

    def refresh(self):
        ''' Method for refreshing treeview '''
        for row in self.window.tree.get_children():
            self.window.tree.delete(row)

        # Add data to tree
        for items in self.data.data:
            self.window.tree.insert('', tk.END, values=items)

if __name__ == '__main__':
    root = tk.Tk()
    controller = Controller(Data(), Window(root))
    root.mainloop()
 

Attachments

  • Kazam_screenshot_00000.png
    Kazam_screenshot_00000.png
    35.3 KB · Views: 3
Last edited:
Updated code to use sqlite database. May still have bugs.

Python:
import tkinter as tk
from tkinter.messagebox import showerror
from tkinter import ttk
import os
from PIL import Image, ImageTk
import sqlite3 as sq

class Data:
    ''' Data class handles the database queries '''
    def __init__(self):
        path = os.path.realpath(os.path.dirname(__file__))
        self.connect = sq.connect(f'{path}/test.db')
        self.cursor = self.connect.cursor()
    def create(self):
        query = '''
            create table if not exists mytable (
            id integer primary key,
            customer text not null,
            receipt integer,
            item text not null,
            amount integer not null
            )
        '''
        self.connect.execute(query)
        self.connect.commit()

    def getdata(self):
        query = 'select * from mytable order by id desc'
        return self.cursor.execute(query).fetchall()
    def getreceipt(self):
        query = 'select receipt from mytable order by receipt desc limit 1'
        res = self.cursor.execute(query).fetchone()
        return res
    def _add(self, data):
        ''' Method for adding to list '''
        query = '''insert into mytable (customer, item, amount)
                    values (?,?,?)'''
        self.cursor.execute(query, data)
        self.connect.commit()
        query = 'update mytable set receipt = id'
        self.cursor.execute(query)
        self.connect.commit()
    def _delete(self, receipt):
        ''' Method for removing items from list '''
        query = f'delete from mytable where receipt = {receipt}'
        self.cursor.execute(query)
        self.connect.commit()

class Window:
    ''' Window class is for presentation '''
    def __init__(self, parent):
        self.parent = parent
        parent.columnconfigure(0, weight=1)
        parent.rowconfigure(0, weight=1)
        
        # Container for holding widgets
        container = tk.Frame(parent)
        container.grid(column=0, row=0, sticky='news')
        container.grid_columnconfigure(0, weight=3, uniform='columns')
        container.grid_columnconfigure(1, weight=3, uniform='columns')
        # container for hold the widgets on the left
        left = tk.Frame(container)
        left['highlightbackground'] = '#999999'
        left['highlightcolor'] = '#999999'
        left['highlightthickness'] = 1
        left.grid(column=0, row=0, sticky='news', padx=4, pady=(2,4))
        left.grid_columnconfigure(1, weight=3)
        # Container for holding widgets on the right
        right = tk.Frame(container)
        right['highlightbackground'] = '#999999'
        right['highlightcolor'] = '#999999'
        right['highlightthickness'] = 1
        right.grid(column=1, row=0, rowspan=2, sticky='news', pady=(2,4))
        right.grid_columnconfigure(0, weight=3)
        # Items for the labels
        items = ('Customer Name', 'Receipt No.:', 'Item:', 'Amount:')
        # Create the labels
        for index, item in enumerate(items):
            label = tk.Label(left, text=item, font=(None, 11, 'bold'), anchor='w')
            label.grid(column=0, row=index, sticky='new', padx=4, pady=4)
        # Create the entry fields
        self.entries = []
        for index, entry in enumerate(items):
            self.entries.append(tk.Entry(left))
            self.entries[index].grid(column=1, row=index, sticky='new', padx=4, pady=4)
        # Create a container to hold the logos
        self.logoframe = tk.Frame(container, pady=8)
        self.logoframe['highlightbackground'] = '#999999'
        self.logoframe['highlightcolor'] = '#999999'
        self.logoframe['highlightthickness'] = 1
        self.logoframe.grid(column=0, row=1, sticky='news', padx=4, pady=4)
        self.logoframe.grid_rowconfigure(0, weight=3)
                
        # Add the powered by text
        label = tk.Label(self.logoframe, text='Powered By:', font=(None, 14, 'bold'))
        label.grid(column=0, row=0, sticky='news', padx=8, pady=8)
        # Create a treeview
        style = ttk.Style()
        style.configure('Treeview', rowheight=25, font=(None, 10, 'normal'))
        columns = ('Customer', 'Receipt No.', 'Item', 'Amount')
        self.tree = ttk.Treeview(right, columns=columns, show='headings', selectmode='browse')
        for column in columns:
            self.tree.heading(column, text=column)
        for column in columns:
            self.tree.column(column, stretch='no', width=130)
        self.tree.grid(column=0, row=0, rowspan=2, sticky='news', padx=4, pady=4)
        # Create a scrollbar
        self.scrollbar = ttk.Scrollbar(right, orient='vertical', command=self.tree.yview)
        self.scrollbar.grid(column=1, row=0, rowspan=2, sticky='ns', padx=2, pady=4)
        self.tree.configure(yscrollcommand=self.scrollbar.set)

        # Container for the buttons
        btnframe = tk.Frame(container)
        btnframe['highlightbackground'] = '#999999'
        btnframe['highlightcolor'] = '#999999'
        btnframe['highlightthickness'] = 1
        btnframe.grid(column=0, columnspan=2, row=5, sticky='new', padx=4, pady=8)
        btnframe.grid_columnconfigure(1, weight=3)
        
        # Create the buttons
        self.addbtn = tk.Button(btnframe, text='Add', bg='skyblue', cursor='hand2', )
        self.addbtn.grid(column=0, row=0, sticky='news', padx=4, pady=4)
        self.addbtn.bind('<Enter>', self.e_add)
        self.delbtn = tk.Button(btnframe, text='Delete', bg='orange', cursor='hand2')
        self.delbtn.grid(column=1, row=0, sticky='e', padx=4, pady=4)
        self.delbtn.bind('<Enter>', self.e_del)
        self.exitbtn = tk.Button(btnframe, text='Exit', bg='tomato', cursor='hand2', command=parent.destroy)
        self.exitbtn.grid(column=2, row=0, sticky='e', padx=4,pady=4)
        self.exitbtn.bind('<Enter>', self.e_enter)
        # Display the logos
        self.get_images()
    # Methods for giving a hover effect and adding the logos
    def e_enter(self, event):
        self.exitbtn.configure(activebackground='red')
    def e_del(self, event):
        self.delbtn.configure(activebackground='orangered')
    def e_add(self, event):
        self.addbtn.configure(activebackground='powderblue')
    def get_images(self):
        ''' Method grabs the logos '''
        path = f'{os.path.realpath(os.path.dirname(__file__))}/images'
        logos = os.listdir(path)
        for index, logo in enumerate(logos):
            image = Image.open(f'{path}/{logo}')
            image = image.resize((80,30))
            image = ImageTk.PhotoImage(image)
            label = tk.Label(self.logoframe, image=image)
            label.grid(column=index+1, row=0, sticky='news',padx=8, pady=8)
            label.image = image
        
class Controller:
    ''' Controller class handles communications between window and data class '''
    def __init__(self, data, window):
        # Make the Data and Window classes available for Controller class
        self.data = data
        self.window = window
        # Create the database if not exist
        self.data.create()
        # Set disabled colors for receipt entry field
        self.window.entries[1].configure(disabledbackground='white', disabledforeground='black')
        # Button commands
        self.window.addbtn.configure(command=self._add)
        self.window.delbtn.configure(command=self._delete)
        # Load treeview with data if any
        self.refresh()
    def _delete(self):
        ''' Method for deleting items from database '''
        # Set the state of receipt field to normal and clear all fields
        self.window.entries[1]['state'] = 'normal'
        for entry in self.window.entries:
            entry.delete(0, tk.END)
        # Try block for getting selected item then delete from database
        try:            
            item = self.window.tree.focus()
            receipt = self.window.tree.item(item)['values'][1]
            self.data._delete(receipt)
            # Refresh treeview
            self.refresh()
        except:
            pass
    def _add(self):
        ''' Method for adding items to the list '''
        # Get the form fields
        entries = self.window.entries
        
        # seperate for easier handling
        customer = entries[0].get()
        item = entries[2].get()
        amount = entries[3].get()
        # A little error checking
        error = 0
        messages = []
        # Available items
        items = ['spoons', 'forks', 'knives', 'tables', 'chairs', 'cater dishes']
        # Customer name required
        if not customer:
            messages.append('Customer name is required.')
            error += 1
        # Item must be in the available items list
        if item.lower() not in items:
            messages.append(f'Item has to be one of: {", ".join(items)}')
            error += 1
        # Try block for checking for positive numbers and within 1 - 500
        try:
            amount = int(amount)
            if amount < 0:
                messages.append('Amount can not be a negative number')
                error += 1
            if amount < 1 or amount > 500:
                messages.append('Amount must be between 1 and 500')
                error += 1
        except ValueError:
            messages.append('Amount must be a whole number')
            error += 1
        # If there are errors display using messagebox
        if error > 0:
            field = 'These fields need' if error > 1 else 'This field needs'
            showerror('Error!', f'{field} to be corrected:\n{"\n".join(messages)}')
            
        # Everything is ok add data to the database
        else:
            # Clear all form fields
            self.window.entries[1]['state'] = 'normal'
            for entry in self.window.entries:
                entry.delete(0, tk.END)
            # Add data to database
            self.data._add((customer,item,amount))
            # Refresh the treeview
            self.refresh()
    def refresh(self):
        ''' Method for refreshing treeview '''
        # Set the receipt field to normal
        self.window.entries[1]['state'] = 'normal'
        # Clear the treeview
        for row in self.window.tree.get_children():
            self.window.tree.delete(row)
        self.window.tree.tag_configure('odd', background='lightyellow')
        self.window.tree.tag_configure('even', background='lightblue')
        # Repopulate treeview with current data
        for index, items in enumerate(self.data.getdata()):
            data = (items[1].title(), f'{items[2]:09}',
                    items[3], items[4])
            if index % 2 == 0:
                self.window.tree.insert('', tk.END, values=data, tags=('odd',))
            else:
                self.window.tree.insert('', tk.END, values=data, tags=('even',))
        # This is used to increase receipt value in form
        # Format to have leading zeros
        # Disable the field so it can't be changed
        receipt = 1 if self.data.getreceipt() == None else self.data.getreceipt()[0]+1
        self.window.entries[1].insert(tk.END, f'{receipt:09}')
        self.window.entries[1]['state'] = 'disabled'

if __name__ == '__main__':
    root = tk.Tk()
    root.title('Party Hire Shop')
    root.resizable(False, False)
    controller = Controller(Data(), Window(root))
    root.mainloop()
 

Attachments

  • Kazam_screenshot_00000.png
    Kazam_screenshot_00000.png
    39.2 KB · Views: 3
Last edited:

New Threads

Buy us a coffee!

Back
Top Bottom