Apr-14-2019, 11:30 AM
(This post was last modified: Apr-14-2019, 11:33 AM by KevinBrown.)
Ref the above for the record I was using .csv files that were in the format.
"Car"
"Bus"
"Train"
"Boat"
"Motor cycle"
In the case of any entry with white space e.g "Motor cycle", this would appear in the combobox as {Motor cycle}
Having looked into this further and the .csv files I was using I can see that
a .csv file in the format ,Car,Bus,Train,Boat,Motor cycle the code below gives me what I was after.
In the case of the user selecting 'Car' as option 1 the callback loads the car options into combobox 2
,Ford,B M W,Seat,Honda,Volkswagen"
I believe that i am now providing .csv files in the correct way and using combobox and csv.reader in the correct way.
"Car"
"Bus"
"Train"
"Boat"
"Motor cycle"
In the case of any entry with white space e.g "Motor cycle", this would appear in the combobox as {Motor cycle}
Having looked into this further and the .csv files I was using I can see that
a .csv file in the format ,Car,Bus,Train,Boat,Motor cycle the code below gives me what I was after.
In the case of the user selecting 'Car' as option 1 the callback loads the car options into combobox 2
,Ford,B M W,Seat,Honda,Volkswagen"
I believe that i am now providing .csv files in the correct way and using combobox and csv.reader in the correct way.
# METHOD #2 with open('Menus_Vend/MAIN.csv', newline='') as csvfile: spamreader = csv.reader(csvfile , delimiter=',') Tup1 = () for Tup1 in spamreader: print(Tup1) csvfile.closed
ComboGrp1 = ttk.Combobox(frame_Grps, width=10) ComboGrp1.place(x=40, y=10) ComboGrp1['values']=(Tup1)
ComboGrp1.bind("<<ComboboxSelected>>", CBackComboGrp1)
def CBackComboGrp1(eventObject): with open('Menus_Vend/'+ (eventObject.widget.get()) +'.csv', newline='') as csvfile: spamreader = csv.reader(csvfile , delimiter=',') Tup2 = () for Tup2 in spamreader: ComboGrp2['values'] = (Tup2) csvfile.closed