Menu

A little bug, I think

2023-08-27
2023-08-31
  • Andrew Mascord

    Andrew Mascord - 2023-08-27

    Hi
    I was trying to regenerate the support file in my project after adding an alias for a custom widget and the Update Question dialog became unresponsive, I poked around looking for a hidden dialog and found that the dialog had appeared in the widget tree and that I could select its widget as in the picture attached
    I stopped page by closing command window as quit wasn't working either and restarted, I tried the same thing again and it worked.

    Does the alias in a custom widget do anything as I cant see it in the code after saving?
    Thanks
    Andrew

     
  • Greg Walters

    Greg Walters - 2023-08-28

    Sorry for the delay getting back to you. Sourceforge is supposed to notify me of any new messages, but for some reason it didn't.

    I'm not sure why things went unresponsive. Sorry about that.
    As to the alias, that's kind of hard to say without seeing your code.
    About the only thing you should see in the support file about the custom widget is a single line near the bottom that looks something like this...

    Custom = tk.Frame  # To be updated by user with name of custom widget.
    

    Would it be possible for you to post the .tcl project file here. I can try to look at it and see if there is anything "odd".

    One quick thing. If you have more than one custom widget in the project, you need to use the variant attribute. This will assign a different alias name. The variant can be a simple single alpha character like "p" or "q".

    The variant attribute creates a separate name to be used in the GUI module and tied to a separate Python widget implementation. If the attribute is given a value (a string of character legal in a Python identifier) then that value is appended to the name ‘Custom’ and that enlarged name is used as the class name in generating the Python code. If the variant attribute is left blank, the class name is ‘Custom’ as before. For instance, if the widget ‘Custom1’ in project ‘d’ is given the variant ‘p’ and the widget ‘Custom2’ is given the variant ‘q’, the following lines are generated in the GUI module, ‘d.py’:

    self.Custom1 = d_support.Customp(top)
    self.Custom1.place(relx=0.35, rely=0.24, relheight=0.16, relwidth=0.21)
    
    self.Custom2 = d_support.Customq(top)
    self.Custom2.place(relx=0.42, rely=0.62, relheight=0.16, relwidth=0.21)
    and the following is generated in the support module ‘d_support.py’:
    
    Customp = Frame
    
    Customq = Frame
    

    I hope this helps.

    Greg

     
  • Greg Walters

    Greg Walters - 2023-08-30

    I just realized that I only answered part of the question.

    The Custom widget by itself really doesn't do anything. It's a "place holder" for another widget.

    In the PAGE distribution folder, there is a folder named "examples". In the examples directory, there is another folder named "ScrolledCheckedListBox". There you will find the complete code for a project that demonstrates a third party widget for PAGE (and Tkinter in general). The custom widget MUST be in the same folder as your code. Just use the example in the customwidgetdemo_support.py file and you'll be using custom widgets with ease.

    You can do an Internet search for "Tkinter widgets" or "Ttk widgets' to find some. A good starting point would be https://github.com/TkinterEP/ttkwidgets , which is a nice collection of widgets that you can try. Some of them already exist in PAGE (in a dfferent form) but many might be helpful for you.

    Greg

     
  • Andrew Mascord

    Andrew Mascord - 2023-08-31

    Hi Greg,
    Sorry about my delay in replying too.

    I wasn't able to duplicate the strange state, and was just letting you know about it. I noted after the post that you haven't used aliases in your examples so I have removed it from my project.

    I now have a grid based on the Sheet library working inside a custom control, which I based on the tksheet1 example.

    I bought your book, very useful, thanks.

    Thanks for your help again :)
    Andrew

     
  • Greg Walters

    Greg Walters - 2023-08-31

    Hello again Andrew,
    I'm glad it was just a one time thing.

    Aliases are something that's kind of a personal preference. Many times, I'll only alias the things that are immediately needed like btnExit or FrameStatus when I'm making a status bar. Most times, thanks to PAGE, the textvars are enough to get me through. If I were to be perfectly honest, the CORRECT way to do it is to alias EVERYTHING. But I became a programmer over 50 years ago because I was lazy and where else could I get a job doing nothing but having fun?

    Thank you for buying the book and I'm glad you are finding it useful.

    Sincerely,
    Greg

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.