ceccopierangiolieugenio / pyTermTk

Python Terminal Toolkit - a Spiced Up Cross Compatible TUI Library 🌶️
https://ceccopierangiolieugenio.github.io/pyTermTk-Docs/
MIT License
598 stars 23 forks source link

Issues with menubar, and overlay windows #179

Closed castben closed 1 year ago

castben commented 1 year ago

Hi hope you are doing well,

I've a couple of issues that I've been trying to fix it last 2 to 4 days but I'm not sure what is going on:

Issue with MenuBar:

I've followed your examples and menu works as I expect, but very initial "render" of menu looks odd:

image

When I click over window (and it gain focus) then it renders properly:

image

Apart of this all works as I expect.

Second Issue, overlay window: On this menu, I'm trying to trigger a "FilePicker" object using overlay window, like you did on your example (calculator.py) or filepicker.py but instead of using a button I was trying to trigger it using Open option I put at the menu File->open it seems to do something but filepicker window simply does not show up...

I've done like this:


   def _showDialog(fm):
        filePicker = ttk.TTkFileDialogPicker(pos=(3, 3), size=(75, 24), caption="Select a file",
                                             path=".",
                                             fileMode=fm,
                                             filter="All Files (*);;logs files (*.log)")
        ttk.TTkHelper.overlay(TTkWindow_logs, filePicker, 4, 8, True)
        filePicker.pathPicked.connect(load_file)

    @pyTTkSlot()
    def file_menu(menuOption):
        """
        Menu file activation
        :param menuOption:
        :return:
        """

        selection = menuOption.text().toAscii()

        if selection == 'Open':
            _showDialog(ttk.TTkK.FileMode.AnyFile)

        if selection == 'Exit':
            root.quit()

    fileMenu = TTkWindow_logs.menubarTop().addMenu("&File")
    viewMenu = TTkWindow_logs.menubarTop().addMenu("&View")
    fileMenu.addMenu("Open")
    fileMenu.addMenu("Close")
    fileMenu.addMenu("Exit")
    viewMenu.addMenu("Show Lines")
    viewMenu.addMenu("Parse Json")

    TTkWindow_logs.sizeChanged.connect(resize_logcontent)
    # TTKTextEdit_logcontent.setLineWrapMode(ttk.TTkK.WordWrap)
    fileMenu.menuButtonClicked.connect(file_menu)
    TTKTextEdit_logcontent.setWrapWidth(250)
    TTKTextEdit_logcontent.setLineWrapMode(ttk.TTkK.FixedWidth)

If I comment out overlay method, and add parent=TTkWindow_logs at the filepicker definition, this works as I expect, but window rendering is limited to TTkWindow_logs frame, and sometimes it doesn't appear complete until I click on it to allow complete rendering.

I'm using following versions: pyTermTk==0.30.0a44 ttkDesigner==0.30.0a44

I will try to update to your last release just in case all these has been fixed there, and I will let you know. Regards

ceccopierangiolieugenio commented 1 year ago

Recently I dropped the version 0.34.0a there are massive changes and some of them are not compatible with the previous versions. please try that version first, I think there is a fix for a similar issue you are experiencing. I hope all the other changer are not breaking your project but i will help you to adapt it to the new version if needed.

ceccopierangiolieugenio commented 1 year ago

about the second issue you can have a look at the ttkdesigner: https://github.com/ceccopierangiolieugenio/pyTermTk/blob/be196d0bc053471af6120a3ee491d78dcfc82fa4/ttkDesigner/app/designer.py#L137

https://github.com/ceccopierangiolieugenio/pyTermTk/blob/be196d0bc053471af6120a3ee491d78dcfc82fa4/ttkDesigner/app/designer.py#L286-L290

https://github.com/ceccopierangiolieugenio/pyTermTk/blob/be196d0bc053471af6120a3ee491d78dcfc82fa4/ttkDesigner/app/designer.py#L272-L284

castben commented 1 year ago

Hi thank you as usual for your quick answer,

I've updated into this version:

pip3 freeze | grep -i tk
pyTermTk==0.34.0a0
ttkDesigner==0.34.0a1

And yes I noticed something change as my program stop working but thankfully was for a minor change for me you changed method menuTopBar to newMenuTopBar which i've also modified, and it ran. I had also to modify calling metod for callback tasks for menu items as they stopped working, but now they look better, and look and feel is also good.

I've also noticed my previous form created with ttkDesigner make it crash, when i tried to load it. But I think is because it was done with previous version of ttkDesigner, thankfully it was very simple form. For now I've recreated it manually.

All is now working as I expect, again thank you very much. You can close this issue.

ceccopierangiolieugenio commented 1 year ago

Thanks