0

i wanted some help with the scrollbar because i've tried many ways and still, i couldn't get a normal result , except just showing the bar but "grey" and not scrollable , i cleaned the code so if someone has any idea , i would appreciate it!

class sales_page(tk.Frame):
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.config(background="#333333")

        TopOfWindowFrame = ctk.CTkFrame(self, bg_color="#333333", fg_color="grey", height=100, )
        TopOfWindowFrame.pack(padx=0, pady=0, fill='x', expand=True, anchor='n')

        labelaoralogo = ctk.CTkLabel(TopOfWindowFrame, image=aoralogo, text='')
        labelaoralogo.pack(padx=5, pady=5, anchor='center', expand=True)

        # SalesPageFramesAndUI
        self.ShowOptionsFrame = ctk.CTkFrame(self, fg_color='white', bg_color='#333333', width=400, height=600)
        self.ShowOptionsFrame.pack(padx=5, pady=5, fill='y', expand=True, side='top', anchor='nw')

        ShowAllSales = ctk.CTkButton(self.ShowOptionsFrame, width=400, height=50, text='Όλες οι πωλήσεις',
                                     font=('robotic bold', 20), hover_color='#4B0082', fg_color='#a881af',
                                     command=lambda: self.AllSalesOrders(),
                                     border_width=3, border_color='black')
        ShowAllSales.place(x=0, y=0)

        ShowSalesByCustomer = ctk.CTkButton(self.ShowOptionsFrame, width=400, height=50, text='Πωλήσεις ανά Πελάτη',
                                            font=('robotic bold', 20), hover_color='#4B0082', fg_color='#a881af',
                                            border_width=3, border_color='black')
        ShowSalesByCustomer.place(x=0, y=47)

    def AllSalesOrders(self):
        CallDB = aoracandlestudiodb.cursor()

        CallDB.execute('SELECT orders_id FROM sales ORDER BY _date')
        AllSales = CallDB.fetchall()
        distance = 60

        self.AllInsideThisFrame = ctk.CTkFrame(self, width=1000, height=750, bg_color="#333333",
                                                                     border_width=8,
                                               border_color="purple", fg_color='white')
        self.AllInsideThisFrame.place(x=450, y=150)

        for sale_id in AllSales:
            get_ID_str = str(sale_id)
            get_sales_ID = get_ID_str[2:-3]
            get_sales_date = get_DateOfSale(get_sales_ID)
            get_sales_price = get_TotalPriceOfSale(get_sales_ID)
            get_sales_customer = get_CustomerOfSale(get_sales_ID)
            self.MakeButtonsForSales(get_sales_date, get_sales_ID, get_sales_price, get_sales_customer, distance)

            distance = distance + 55

    def MakeButtonsForSales(self, Sales_Date, Sales_ID, Sales_price, Sales_Customer, distance):
        SalesTypeLabel = ctk.CTkLabel(self.AllInsideThisFrame, width=980, height=50, text='Όλες οι πωλήσεις',
                                      font=('arial bold', 25), text_color='black')
        SalesTypeLabel.place(x=10, y=10)
        self.SaleButton = ctk.CTkButton(self.AllInsideThisFrame, width=980, height=50,hover_color='#4B0082', fg_color='#a881af',
                                        text=(
                                                'Ημερομηνία: ' + Sales_Date + "                      "
                                                                              "Σύνολο Παραγγελίας: " + Sales_price +
                                                "                      Πελάτης: " + Sales_Customer),
                                        command=lambda: self.MakeLabelsForItemsInSales(Sales_ID, Sales_Customer,
                                                                                       Sales_price, Sales_Date),
                                        font=('Arial', 15), border_width=5, border_color='black')
        self.SaleButton.place(x=10, y=distance)

All the buttons are made, are too many and that's why i need the scrollbar, ShowAllSales button is making a new frame full of "sales" buttons inside a frame which is called "self.AllInsideThisFrame" i did try to make a scrollable frame full of texts and it worked , i dont how to do the same with buttons , i think i am doing something wrong. So the scrollable frame must be "self.AllInsideThisFrame" Thank you very much for your time

  • There is no scrollbar created in your code. Also a frame does not support scrolling. – acw1668 May 29 '23 at 00:26
  • Please have a look at the help center for [tips about how to improve your question](https://stackoverflow.com/help/how-to-ask), and in particular, make your code a [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) so that people reading your question can reproduce your issue without needing to guess the imports or read through code irrelevant to the issue. – j_4321 May 29 '23 at 15:23
  • 1
    Also, have look at this similar questions https://stackoverflow.com/questions/3085696/adding-a-scrollbar-to-a-group-of-widgets-in-tkinter/3092341#3092341, I think the answers can help you – j_4321 May 29 '23 at 15:26

0 Answers0