Bueno estoy diseñando una UI para un programa... todo es relativamente precario pues estoy aprendiendo poco a poco como manejarlo. He conseguido insertar un scrollbar dentro del listbox, sin embargo el problema radica en que el scrollbar no desaparece nunca, ni cuando no hay elementos en el listbox. Estoy probando usando Grid, imagino que con pack se puede hacer de otra manera, lo digo pq por ahora me interesa hacerlo con este comando.
El codigo:
import os, sys
import win32api
import platform
import gettext
import locale
import sys
from time import sleep
#GUI para EACUI
try:
import tkinter
from tkinter import *
except ImportError:
raise ImportError("Se requiere el modulo Tkinter")
#Configure gettext Define the '_()' function
APP_NAME = "EACUI"
LOCALE_DIR = ('C:\Locale\es\LC_MESSAGES')
gettextt = gettext.translation(APP_NAME, LOCALE_DIR,fallback=True)
_ = gettextt.gettext
#Ventana
root = tkinter.Tk(screenName=None, baseName=None, className='Tk', useTk=1)
'''Titulos'''
root.wm_title("Eac3to GUI v0.0")
#root.title("Eac3to GUI v0.0")
root.wm_frame()
'''Etiqueta'''
#etiqueta=tkinter.Label(root,text="Eac3to GUI v0.0")
#etiqueta.grid(row=1, column=1)
'''Dimension ventana'''
root.wm_maxsize(1000, 1000)
root.wm_minsize(640,640)
root.wm_geometry('640x640')
root.wm_iconbitmap('.\icon.ico')
'''Menus'''
#File
menu = tkinter.Menu(root)
root.config(menu=menu)
menu1_1 = tkinter.Menu(menu, tearoff=0)
menu.add_cascade(label=_("File"), menu=menu1_1)
menu1_1.add_command(label=_("Open"))
menu1_1.add_command(label=_("Close"))
#Options
menu1_2 = tkinter.Menu(menu, tearoff=0)
menu.add_cascade(label=_("Options"), menu=menu1_2)
menu1_2.add_command(label=_("Setup"),command=lambda: setup(_("Setup")))
menu1_2.add_separator()
menu1_2_1 = tkinter.Menu(menu1_2, tearoff=0)
menu1_2.add_cascade(label=_("Language"), menu=menu1_2_1)
menu1_2_1.add_command(label=_("English"),command=lambda: language(_("English")))
menu1_2_1.add_command(label=_("Spanish"),command=lambda: language(_("Spanish")))
#Help
menu1_3 = tkinter.Menu(menu1_2, tearoff=0)
menu.add_cascade(label=_("Help"), menu=menu1_3)
menu1_3.add_command(label=_("About"),command=lambda: about(_("About")))
'''Ventana de carga con scrollbar interno usando Grid'''
text = tkinter.Listbox(root)
text.grid(padx=10,pady=10)
text.bindtags((text, root, "all"))
#for i in range(20):
#text.insert(i,i)
scrl = Scrollbar(root, command=text.yview)
text.config(yscrollcommand=scrl.set)
scrl.grid_rowconfigure(10)
#scrl.grid(ipadx=200,ipady=20,sticky='e',rowspan=5)
scrl.grid(in_=text,ipadx=200,ipady=20,sticky='ns')
'''Ventana de carga'''
#windows_load=tkinter.Text(root,height = 1, width=int(root.winfo_width())-580,font=("Times", 12),state=tkinter.NORMAL, cursor='arrow',insertwidth=2,exportselection=1)
#windows_load=tkinter.Listbox(root,height=10,width=int(root.winfo_width())-580)
#windows_load.bindtags((windows_load, root, "all"))
#for i in range(20):
#windows_load.insert(i,i)
#windows_load.pack(anchor='nw',side=TOP, fill=Y, expand=FALSE,padx=10,pady=10)
'''Ejecucion'''
root.mainloop()
¿En donde estoy metiendo la pata?
usa mejor wx para python, es mas profesional.
No es por quitarte la nota, pero mejor Usa PyQT4 , lo agradeceras, nadie usa Tk/Tkinter.
Saludos