0
from tkinter import *
from tkinter import ttk
import sqlite3
import os
import sys
import datetime

connection = sqlite3.connect("employees.db")
cursor = connection.cursor()

class Main(object):
    def __init__(self, master):
        self.master = master

        #<-----Defining Frames----->
        main_frame = Frame(self.master)
        main_frame.pack()

        top_frame = Frame(main_frame, width = 1250, height = 50, bg = '#f8f8f8', padx = 20, relief = SUNKEN, borderwidth = 1)
        top_frame.pack(side = TOP, fill = X)

        top_right_frame = Frame(top_frame, width = 100, height = 20, bg = '#f8f8f8', relief = SUNKEN, borderwidth = 0)
        top_right_frame.pack(side = RIGHT)

        center_frame = Frame(main_frame, width = 1350, height = 690, relief = RIDGE, bg = '#e6e6ff', borderwidth = 1)
        center_frame.pack(side = TOP)

        left_center_frame = Frame(center_frame, width = 180, height = 690, relief = SUNKEN, bg = '#e6e6ff', borderwidth = 1)
        left_center_frame.pack(side = LEFT, fill = BOTH)
        left_center_frame.pack_propagate(0)

        right_center_frame = Frame(center_frame, width = 1170, height = 690, relief = SUNKEN, bg = '#e6e6ff', borderwidth = 1)
        right_center_frame.pack()
        right_center_frame.pack_propagate(0)

        bottom_frame = Frame(main_frame, width = 1350, height = 10, relief = SUNKEN, bg = '#8080ff', borderwidth = 0)
        bottom_frame.pack(side = BOTTOM, fill = X)

        swap_type_frame = LabelFrame(left_center_frame, width = 250, height = 50, text = "Swap Type", bg = '#e6e6ff', padx = 5, pady = 5)
        swap_type_frame.pack(side = TOP, fill = BOTH, padx = 5, pady = 5)

        #<-----Defining Labels----->
        label_main_title = Label(top_frame, text = "Advisor Roster Swap", bg = '#f8f8f8', font = ("TIMES",20), justify = CENTER)
        label_main_title.pack()

        label_current_day = Label(top_right_frame, text = timeDetails().current_date(), bg = '#f8f8f8', font = ("Times New Roman",10), anchor = NE)
        label_current_day.pack(side = RIGHT)

        label_bottom_frame = Label(bottom_frame, text = "© Vodafone WFM | RTA", font = ("Times New Roman",10), justify = CENTER, fg= '#ffffff', bg = '#8080ff' )
        label_bottom_frame.pack(side = BOTTOM)

        swap_type = ['One Way Swap', 'Two Way Swap', 'One Way CL Swap', 'Two Way CL Swap']
        swap_type_combobox = ttk.Combobox(swap_type_frame, value = swap_type, width = 21)
        swap_type_combobox.current(0)
        swap_type_combobox.grid(row = 2, column = 1, pady = 5)


class Single_Advisor(object):
    def __init__(self, master):
        self.master = master

        single_advisor_frame = LabelFrame(right_center_frame, width = 1150, height = 200, text = "Advisor Details", bg = '#e6e6ff', padx = 5, pady = 5)
        single_advisor_frame.pack(side=TOP, fill=Y, padx = 5, pady = 5)


class Multiple_Advisors(object):
    def __init__(self, master):
        self.master = master

        multiple_advisor_frame = LabelFrame(right_center_frame, width = 1150, height = 200, text = "Advisor Details", bg = '#e6e6ff', padx = 5, pady = 5)
        multiple_advisor_frame.pack(side=TOP, fill=Y, padx = 5, pady = 5)


class timeDetails():
    def current_date(self):
        now =  datetime.datetime.now()
        return now.strftime("%A, %B %d")


def main():
    root = Tk()
    app = Main(root)
    root.title("Advisor Roster Swap")
    root.geometry("1350x750+350+200")
    root.resizable(width = FALSE, height = FALSE)
    root.mainloop()


if __name__ == '__main__':
    main()

Hello, I want to hide/show frame and it's labels/widgets/boxes etc which will depend on the user selection in combo box. When selected, correct frame should appear which I have mentioned in class so that they can have one way swap or 2 way swap. One way would have employee code boxes along with 7 boxes(shifts and offs) and 2 way will have 2 employee codes boxes along with 7X2 boxes for shifts and offs.

  • 1
    ***"I want to hide/show frame..."***: What is stopping you to do so...? – stovfl Mar 17 '20 at 20:55
  • my code won't work, can you please show an example: 1 . get selected value from combobox 2.. based on selected value, enable correct frame ? – Ankur Khera Mar 17 '20 at 21:01
  • ***"my code won't work"***: [Edit] your example per the [mcve] guidelines. I don't have `"employees.db"` to run it. Read up on [getting-the-selected-value-from-combobox-in-tkinter](https://stackoverflow.com/questions/31264522) – stovfl Mar 17 '20 at 21:04
  • employees.db is blank database and this will be added later on...Please check it will still run – Ankur Khera Mar 17 '20 at 21:06
  • Add some hard-coded data to the example. A [mcve] that relies on an external database isn't very useful. – Bryan Oakley Mar 17 '20 at 21:24
  • Hi, database it not an issue and this will be sorted later on... I want the frame to appear when user makes selection from combobox.. – Ankur Khera Mar 17 '20 at 21:26

0 Answers0