Foros Python

Versión completa: Scrollbar horizontal no funciona
Actualmente estas viendo una versión simplificada de nuestro contenido. Ver la versión completa con el formato correcto.
Buen dia!!!

Estoy haciendo una aplicacion de escritorio donde coloco un scrollbar horizontal el problema es que no funciona, utilice un programa prueba y funciona pero cuando lo coloco en mi programa principal la scrollbar desaparece, alguien que pueda orientarme???
dejo mi codigo para que le den un vistazo en la parte de abajo coloque un comment de cual scrollbar es horizontal y vertical 

       
       self.wind = window
       self.wind.title('Vitasis Laboratorio Médico')
       self.wind.configure(background = 'gray')
       self.wind.geometry('1210x823')
       #self.wind.resizable(0, 0)
       
       #Pestañas
       self._tab_control = ttk.Notebook(self.wind)
       self._tab_control.grid(row= 1, column = 0)
       self.tab2 = ttk.Frame(self._tab_control)
       self._tab_control.add(self.tab2, text="Pacientes", compound=tk.TOP)

       columns = ('#1', '#2', '#3', '#4', '#5', '#6', '#7', '#8', '#9', '#10', '#11', '#12', '#13', '#14', '#15', '#16', '#17', '#18', '#19')
       self.tree2 = ttk.Treeview(self.tab2, show='headings', height=3, columns=columns)
       self.tree2.grid(row=0, column=0, columnspan=2, sticky = tk.W+tk.E+tk.N+tk.S)
       self.tree2.grid_rowconfigure(0, weight=1)
       self.tab2.grid_columnconfigure(0, weight=1)
       self.tab2.grid_columnconfigure(1, weight=1)
     
     
       self.tree2.column("#1", width=50, minwidth=270, stretch=tk.NO)
       self.tree2.column("#2", width=150, minwidth=150, stretch=tk.NO)
       self.tree2.column("#3", width=150, minwidth=200)
       self.tree2.column("#4", width=150, minwidth=270, stretch=tk.NO)
       self.tree2.column("#5", width=50, minwidth=270, stretch=tk.NO)
       self.tree2.column("#6", width=100, minwidth=270, stretch=tk.NO)
       self.tree2.column("#7", width=290)
       self.tree2.column("#8", width=290) # Prueba Clinica 2
       self.tree2.column("#9", width=290) # Prueba Clinica 3
       self.tree2.column("#10", width=290) # Prueba Clinica 4
       self.tree2.column("#11", width=290) # Prueba Clinica 5
       self.tree2.column("#12", width=100) # Fecha de estudio
       self.tree2.column("#13", width=100) # Fecha de entrega
       self.tree2.column("#14", width=50) # Atendido
       self.tree2.column("#15", width=100) # Promocion
       self.tree2.column("#16", width=100) #Subtotal
       self.tree2.column("#17", width=100) # Anticipo
       self.tree2.column("#18", width=100) # Total
       self.tree2.column("#19", width=100) # Saldo a pagar

       self.tree2.heading('#1', text='Folio', anchor=tk.CENTER)
       self.tree2.heading('#2', text='Nombre', anchor=tk.CENTER)
       self.tree2.heading('#3', text='Dirección', anchor=tk.CENTER)
       self.tree2.heading('#4', text='Teléfono', anchor=tk.CENTER)
       self.tree2.heading('#5', text='Edad', anchor=tk.CENTER)
       self.tree2.heading('#6', text='Sexo', anchor=tk.CENTER)
       self.tree2.heading('#7', text='Prueba Clinica 1', anchor=tk.CENTER)
       self.tree2.heading('#8', text='Prueba Clinica 2', anchor=tk.CENTER)
       self.tree2.heading('#9', text='Prueba Clinica 3', anchor=tk.CENTER)
       self.tree2.heading('#10', text='Prueba Clinica 4', anchor=tk.CENTER)
       self.tree2.heading('#11', text='Prueba Clinica 5', anchor=tk.CENTER)
       self.tree2.heading('#12', text='Fecha de estudio', anchor=tk.CENTER)
       self.tree2.heading('#13', text='Fecha de entrega', anchor=tk.CENTER)
       self.tree2.heading('#14', text='Atendido', anchor=tk.CENTER)
       self.tree2.heading('#15', text='Promoción', anchor=tk.CENTER)
       self.tree2.heading('#16', text='Subtotal', anchor=tk.CENTER)
       self.tree2.heading('#17', text='Anticipo', anchor=tk.CENTER)
       self.tree2.heading('#18', text='Total', anchor=tk.CENTER)
       self.tree2.heading('#19', text='Saldo a pagar', anchor=tk.CENTER)
       
      # Scrollbar vertical#########################################################

       vsb = ttk.Scrollbar(self.tab2, orient="vertical", command=self.tree2.yview)
       vsb.grid(row=0, column=1, sticky= N + S)
       self.tree2.configure(yscrollcommand=vsb.set)

       # Scrollbar Horizontal########################################################

       hsb = ttk.Scrollbar(self.tab2, orient="horizontal", command=self.tree2.xview)
       hsb.grid(row = 1, column=0, sticky = W + E)
       self.tree2.configure(xscrollcommand = hsb.set)
       self.get_pacients()
(15-07-2019, 05:22 PM)Johnny_LS escribió: [ -> ]Buen dia!!!

Estoy haciendo una aplicacion de escritorio donde coloco un scrollbar horizontal el problema es que no funciona, utilice un programa prueba y funciona pero cuando lo coloco en mi programa principal la scrollbar desaparece, alguien que pueda orientarme???
dejo mi codigo para que le den un vistazo en la parte de abajo coloque un comment de cual scrollbar es horizontal y vertical 

       
       self.wind = window
       self.wind.title('Vitasis Laboratorio Médico')
       self.wind.configure(background = 'gray')
       self.wind.geometry('1210x823')
       #self.wind.resizable(0, 0)
       
       #Pestañas
       self._tab_control = ttk.Notebook(self.wind)
       self._tab_control.grid(row= 1, column = 0)
       self.tab2 = ttk.Frame(self._tab_control)
       self._tab_control.add(self.tab2, text="Pacientes", compound=tk.TOP)

       columns = ('#1', '#2', '#3', '#4', '#5', '#6', '#7', '#8', '#9', '#10', '#11', '#12', '#13', '#14', '#15', '#16', '#17', '#18', '#19')
       self.tree2 = ttk.Treeview(self.tab2, show='headings', height=3, columns=columns)
       self.tree2.grid(row=0, column=0, columnspan=2, sticky = tk.W+tk.E+tk.N+tk.S)
       self.tree2.grid_rowconfigure(0, weight=1)
       self.tab2.grid_columnconfigure(0, weight=1)
       self.tab2.grid_columnconfigure(1, weight=1)
     
     
       self.tree2.column("#1", width=50, minwidth=270, stretch=tk.NO)
       self.tree2.column("#2", width=150, minwidth=150, stretch=tk.NO)
       self.tree2.column("#3", width=150, minwidth=200)
       self.tree2.column("#4", width=150, minwidth=270, stretch=tk.NO)
       self.tree2.column("#5", width=50, minwidth=270, stretch=tk.NO)
       self.tree2.column("#6", width=100, minwidth=270, stretch=tk.NO)
       self.tree2.column("#7", width=290)
       self.tree2.column("#8", width=290) # Prueba Clinica 2
       self.tree2.column("#9", width=290) # Prueba Clinica 3
       self.tree2.column("#10", width=290) # Prueba Clinica 4
       self.tree2.column("#11", width=290) # Prueba Clinica 5
       self.tree2.column("#12", width=100) # Fecha de estudio
       self.tree2.column("#13", width=100) # Fecha de entrega
       self.tree2.column("#14", width=50) # Atendido
       self.tree2.column("#15", width=100) # Promocion
       self.tree2.column("#16", width=100) #Subtotal
       self.tree2.column("#17", width=100) # Anticipo
       self.tree2.column("#18", width=100) # Total
       self.tree2.column("#19", width=100) # Saldo a pagar

       self.tree2.heading('#1', text='Folio', anchor=tk.CENTER)
       self.tree2.heading('#2', text='Nombre', anchor=tk.CENTER)
       self.tree2.heading('#3', text='Dirección', anchor=tk.CENTER)
       self.tree2.heading('#4', text='Teléfono', anchor=tk.CENTER)
       self.tree2.heading('#5', text='Edad', anchor=tk.CENTER)
       self.tree2.heading('#6', text='Sexo', anchor=tk.CENTER)
       self.tree2.heading('#7', text='Prueba Clinica 1', anchor=tk.CENTER)
       self.tree2.heading('#8', text='Prueba Clinica 2', anchor=tk.CENTER)
       self.tree2.heading('#9', text='Prueba Clinica 3', anchor=tk.CENTER)
       self.tree2.heading('#10', text='Prueba Clinica 4', anchor=tk.CENTER)
       self.tree2.heading('#11', text='Prueba Clinica 5', anchor=tk.CENTER)
       self.tree2.heading('#12', text='Fecha de estudio', anchor=tk.CENTER)
       self.tree2.heading('#13', text='Fecha de entrega', anchor=tk.CENTER)
       self.tree2.heading('#14', text='Atendido', anchor=tk.CENTER)
       self.tree2.heading('#15', text='Promoción', anchor=tk.CENTER)
       self.tree2.heading('#16', text='Subtotal', anchor=tk.CENTER)
       self.tree2.heading('#17', text='Anticipo', anchor=tk.CENTER)
       self.tree2.heading('#18', text='Total', anchor=tk.CENTER)
       self.tree2.heading('#19', text='Saldo a pagar', anchor=tk.CENTER)
       
      # Scrollbar vertical#########################################################

       vsb = ttk.Scrollbar(self.tab2, orient="vertical", command=self.tree2.yview)
       vsb.grid(row=0, column=1, sticky= N + S)
       self.tree2.configure(yscrollcommand=vsb.set)

       # Scrollbar Horizontal########################################################

       hsb = ttk.Scrollbar(self.tab2, orient="horizontal", command=self.tree2.xview)
       hsb.grid(row = 1, column=0, sticky = W + E)
       self.tree2.configure(xscrollcommand = hsb.set)
       self.get_pacients()

Buenas:

Creo que para que las scrollbar funcionen correctamente hay que "jugar" con el widget Canvas. Te pongo un ejemplo con dos scrollbar que a mí me ha funcionado con una salvedad, las scrollbar no son "autoexpandibles" es decir están limitadas a lo que yo le especifique. (Aún no he conseguido hacer que un scrollbar funcione de manera que se vaya expandiendo según se añade texto o lo que sea.(Es una tarea pendiente).

Código:
    # PANEL 11 (With 2 Scrollbar)
        
        
    self.frame11 = ttk.Frame(self.frame_can, width=1425, height=200, style="BG.TFrame")
    self.frame11.grid(row=5, column=0)
        
    self.scroll11 = ttk.Scrollbar(self.frame11, orient='vertical')
    self.scroll11.grid(row=0, column=1, sticky=N+S)
        
    self.scroll11a = ttk.Scrollbar(self.frame11, orient='horizontal')
    self.scroll11a.grid(row=1, column=0, sticky=W+E)
        
    self.canvas11 = Canvas(self.frame11,bg='#1A1A1F', width=1100, height=200)
    self.canvas11.grid(row=0, column=0, sticky=N+S+E+W)
        
    self.scroll11.configure(command=self.canvas11.yview)
        
    self.scroll11a.configure(command=self.canvas11.xview)
        
    self.canvas11.configure(yscrollcommand=self.scroll11.set)
        
    self.canvas11.configure(xscrollcommand=self.scroll11a.set, scrollregion=(0,0,1775,1000))
        
    self.canvas11.config(scrollregion=self.canvas11.bbox("ALL"))
    
    self.frame_can11 = ttk.Frame(self.canvas11, style="BG.TFrame")
        
    self.canvas11.create_window(0,0, window=self.frame_can11, anchor="nw")
        
    # LABELS PANEL 11
        
    self.serpre = ttk.Label(self.frame_can11, text='PANEL INFORMATIVO DISPOSITIVOS', style="STYL.TLabel")
    self.serpre.grid(row=0, column=0)
        
    # TREEVIEW PANEL 11
        
    self.info = ttk.Treeview(self.frame_can11, style="STCCLView.Treeview", columns=('col1', 'col2','col3', 'col4', 'col5', 'col6'))
    self.info.grid(row=1, column=0, ipady=1600)
        
        
    self.info.heading("#0", text='FECHA')
    self.info.heading('col1', text='EVENTO')
    self.info.heading('col2', text='HORARIO')
    self.info.heading('col3', text='LOCALIDAD')
    self.info.heading('col4', text='RECURSOS ASOCIADOS')
    self.info.heading('col5', text='INFO ADICIONAL')
    self.info.heading('col6', text='CIRCULAR')
    self.info.column("#0", width=125, anchor='center')
    self.info.column('col1', width=250, anchor='center')
    self.info.column('col2', width=175, anchor='center')
    self.info.column('col3', width=250, anchor='center')
    self.info.column('col4', width=325, anchor='center')
    self.info.column('col5', width=400, anchor='center')
    self.info.column('col6', width=250, anchor='center')

P.D. A ver si otras personas con más experiencia que yo te ayudan más que yo, porque yo aún estoy aprendiendo.
Agradezco tu respuesta amigo Myszowor, de hecho he visto en muchos foros que usando canvas hacen la mayoria de las scrollbars en el mio simplemente lo quiero ocupar para desplazar mis columnas en un tree voy a jugar con canvas para intentar solucionar esto ya que llevo 1 semana sin poder tener una solucion y ya me atoré, tomare tu ejemplo para poder ajustarlo a mi programa
Saludos!!!