LoginSignup
1
0

More than 1 year has passed since last update.

【Python】combox初期値の設定方法

Last updated at Posted at 2022-10-18

<初めに>
Tkinterを色々触っていくうちに、あれやりたいこれやりたいと欲が出てきて
なかなかTkinterを活用したアプリ完成まで到達せず…
そんな中でcomboxの初期表示をしたかったのでやり方をメモ程度に残します

<やりたいこと>
comboxのリストを選択する前に指定の文字を表示させたい
(理想↓)
combox_2.jpg

<完成したコード>

item_list = ['test_1', 'test_2', 'test_3']  #選択リスト
test_combobox = ttk.Combobox(frame_move, values=item_list, state='readonly')
    #frame_move → comboxを置きたいウィンドウ名
    #values → 選択リスト
    #state → 選択リスト以外の入力は出来ない様にしている
test_combobox.set("start_combox")#combox初期表示
test_combobox.place(x=5, y=500)#combox設置位置

<解説>
test_combobox.set() → ここで、初期値を入力できる

<終わりに>
Tkinterってやればやるほど沼にはまっていく…
ユーザーがどんな形を求めているかとか
どうゆう形が使いやすいのかとか色々考える内に一日が過ぎていく…
正直、深みにはまらずに簡単に終わらせた方がいいんだよね…

以上(^^)!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0