Closed lildinti closed 2 years ago
Hola Claudio!.
El widget ttk.Panedwindow no tiene opción para configurar minsize. Solo la version vieja del widget lo tiene, es decir, tk.PanedWindow.
Para ttk.Panedwindow, se puede ajustar el tamaño de los paneles según la posición del "sash" al moverlo. El siguiente ejemplo funciona para dos panes horizontales.
#!/usr/bin/python3
import pathlib
import pygubu
PROJECT_PATH = pathlib.Path(__file__).parent
PROJECT_UI = PROJECT_PATH / "issue262.ui"
class Issue262App:
def __init__(self, master=None):
self.builder = builder = pygubu.Builder()
builder.add_resource_path(PROJECT_PATH)
builder.add_from_file(PROJECT_UI)
# Main widget
self.mainwindow = builder.get_object("top1", master)
builder.connect_callbacks(self)
self.panedwin = builder.get_object('panedwin')
self.panedwin.bind('<ButtonRelease-1>', self._adjust_panes_minsize)
def _adjust_panes_minsize(self, event):
left_minsize, right_minsize = (100, 80)
width = self.panedwin.winfo_width()
sash_index = 0
position = self.panedwin.sashpos(sash_index)
if position < left_minsize:
self.panedwin.sashpos(sash_index, left_minsize)
if (width - position) < right_minsize:
self.panedwin.sashpos(sash_index, width - right_minsize)
def run(self):
self.mainwindow.mainloop()
if __name__ == "__main__":
app = Issue262App()
app.run()
issue262.ui
<?xml version='1.0' encoding='utf-8'?>
<interface version="1.2">
<object class="tk.Toplevel" id="top1">
<property name="geometry">320x200</property>
<property name="height">200</property>
<property name="width">200</property>
<child>
<object class="ttk.Panedwindow" id="panedwin">
<property name="height">200</property>
<property name="orient">horizontal</property>
<property name="width">200</property>
<layout manager="pack">
<property name="expand">true</property>
<property name="fill">both</property>
<property name="side">top</property>
</layout>
<child>
<object class="ttk.Panedwindow.Pane" id="pane1">
<property name="weight">1</property>
<child>
<object class="tk.Canvas" id="canvas1">
<property name="background">#009400</property>
<layout manager="pack">
<property name="side">top</property>
</layout>
</object>
</child>
</object>
</child>
<child>
<object class="ttk.Panedwindow.Pane" id="pane2">
<property name="weight">1</property>
<child>
<object class="tk.Canvas" id="canvas2">
<property name="background">#0056d9</property>
<layout manager="pack">
<property name="side">top</property>
</layout>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>
PS: Ale, agregue nuevo ejemplo en my github.
Dale, ya lo revisaré.
Saludos! Alejandro A.
Gracias Ale! Makes sense. Estoy terminando un ejemplo de calculadora. Watch out! :-)
Hi Ale. tengo un. par de preguntas no relacionadas a este topico (ya se, lugar equivocado, pero no hay a discussions section in the git). Ok, pregunta 1: I have a main window with a button and label and a second top level (on same UI file) con un entry field and a button. El boton en main window abre top level two. pasando valor back to main window es ok using same tkvariable en ambos toplevel. sin embargo, cuando trato de abrir toplevel2(child) it doesn't. tengo que crear el builder para toplevel2, etc every time? mire los ejemplos pero no veo nada que me de una idea.
pregunta 2 (posted on discussion section of designer git): como centrar toplevel en pantalla?
de nuevo disculpame el posting aca y gracias por tu ayuda, siempre. Claudio
Hello Claudio,
pregunta 1: I have a main window with a button and label and a second top level (on same UI file) con un entry field and a button. El boton en main window abre top level two. pasando valor back to main window es ok using same tkvariable en ambos toplevel. sin embargo, cuando trato de abrir toplevel2(child) it doesn't. tengo que crear el builder para toplevel2, etc every time? mire los ejemplos pero no veo nada que me de una idea.
This gets easy with the pygubu Dialog widget. It's a Toplevel that can be runned in modal or non modal state. I added some usage examples here
If the logic of the dialog is simple, you can done all with one builder. Just create the dialog at application start and then, call connect_callbacks so all get connected ok (see demo1 and demo2)
If the logic of the dialog is complex, I think is better to isolate all dialog code in one class. Here you will have to create one different builder for the dialog (see demo3). Another example is the is the pygubu-designer "Save As" dialog.
Let me know if this helps.
Regards Alejandro A.
Hola desde Australia!
Pregunta: Como configurar "minsize" for a panedwindow.panel? Probe: get_object('panelname').config(minisize=200). error:: en config...en referencia a la linea previa. Cheers, Claudio
PS: Ale, agregue nuevo ejemplo en my github.