Python Forum
textfile to customtkinter combobox
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
textfile to customtkinter combobox
#4
(Aug-30-2023, 03:43 PM)menator01 Wrote: One way

import tkinter as tk
from tkinter import ttk
import os

path = os.path.dirname(os.sys.argv[0])
if not path:
    path = '.'


file = f'{path}/country.txt'

with open(file, 'r') as lines:
    country = [line.strip() for line in lines]

root = tk.Tk()
root.geometry('400x200+300+300')

label = tk.Label(root, text='Combobox', font=(None, 14, 'bold'))
label.pack(side='top')

combobox = ttk.Combobox(root)
combobox['values'] = country
combobox['font'] = (None, 14, 'normal')
combobox.current(0)
combobox.pack(fill='x')
root.mainloop()

Thank You, values shows nicely in combobox
Reply


Messages In This Thread
textfile to customtkinter combobox - by janeik - Aug-30-2023, 01:49 PM
RE: textfile to customtkinter combobox - by janeik - Aug-30-2023, 09:07 PM
RE: textfile to customtkinter combobox - by janeik - Aug-31-2023, 12:27 AM
RE: textfile to customtkinter combobox - by janeik - Aug-31-2023, 12:21 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Importing python data to Textfile or CSV yanDvator 0 1,820 Aug-02-2020, 06:58 AM
Last Post: yanDvator
  Replace Line in Textfile Deadline 1 10,476 Nov-04-2019, 07:14 PM
Last Post: Larz60+
  Compare input() to textfile Trianne 4 3,614 Sep-29-2018, 02:32 PM
Last Post: gruntfutuk
  Write from URL with changing information to textfile wmc326 1 3,064 Jul-12-2017, 07:10 PM
Last Post: wavic
  Loop thru textfile, change 3 variables for every line herbertioz 11 9,346 Nov-10-2016, 04:56 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020