Python Forum
The PMW Notebook Widget
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The PMW Notebook Widget
#1
I am working in Python 3.7.3. I am trying to make use of the Pmw Notebook widget. When I try to declare a widget of this type it returns the following error:
Error:
Traceback (most recent call last): File "E:\WORK_SPACE\NoteBook_Tester.py", line 26, in <module> nb = pmw.NoteBook(root) File "C:\Users\matta\AppData\Local\Programs\Python\Python37-32\lib\site-packages\Pmw\Pmw_2_0_1\lib\PmwNoteBook.py", line 60, in __init__ Pmw.Color.bordercolors(self, self['hull_background']) File "C:\Users\matta\AppData\Local\Programs\Python\Python37-32\lib\site-packages\Pmw\Pmw_2_0_1\lib\PmwColor.py", line 364, in bordercolors '#%04x%04x%04x' % (lightRGB[0], lightRGB[1], lightRGB[2]), TypeError: %x format: an integer is required, not float
I opened the Pmw.Color class module and replaced the following code:

    return (
        '#%04x%04x%04x' % (lightRGB[0], lightRGB[1], lightRGB[2]),
        '#%04x%04x%04x' % (darkRGB[0], darkRGB[1], darkRGB[2])
    )
with:

    return (
        '#%04x%04x%04x' % (int(lightRGB[0]), int(lightRGB[1]), int(lightRGB[2])),
        '#%04x%04x%04x' % (int(darkRGB[0]), int(darkRGB[1]), int(darkRGB[2]))
    )
By casting the RGB color components to int the widget works. However, I am worried about deployment. Users of my application will be using the original Pmw.Color class. Have I overworked the problem? Is there an easier solution?

Matthew
Reply
#2
What is Pmw, is it compatible with Python 3.7.3, what is the code you are running, can you pass in integers instead of floats in your code.
Reply
#3
Pmw referring to python mega widget. When I try to declare a widget of this type it throws the above error. I copied and pasted a number of examples from the web and they threw the same error. From the output error, I opened the pmw.Color module in the Python installation directory and changed the erroneous line with the cast statements, and the widget now appears on the screen. I am hoping there is a top-level fix (basic code, rather than changing the pmw module code)to this problem. Here is my code:

import tkinter as tk
import tkinter.ttk as ttk
import Pmw as pmw

root = tk.Tk()
root.geometry("800x600")
pmw.initialise()

notebook = pmw.NoteBook(root)
notebook.pack(side='top', anchor='w', padx=50, pady=50)
root.mainloop()
Which produces the following error:

Error:
Traceback (most recent call last): File "E:\WORK_SPACE\NoteBook_Tester.py", line 18, in <module> notebook = pmw.NoteBook(root) File "C:\Users\matta\AppData\Local\Programs\Python\Python37-32\lib\site-packages\Pmw\Pmw_2_0_1\lib\PmwNoteBook.py", line 60, in __init__ Pmw.Color.bordercolors(self, self['hull_background']) File "C:\Users\matta\AppData\Local\Programs\Python\Python37-32\lib\site-packages\Pmw\Pmw_2_0_1\lib\PmwColor.py", line 364, in bordercolors '#%04x%04x%04x' % (lightRGB[0], lightRGB[1], lightRGB[2]), TypeError: %x format: an integer is required, not float
Reply
#4
https://sourceforge.net/p/pmw/bugs/51/ Wrote:Pmw.Color.bordercolors() fails in Python 3. It seems to be assuming integer division. The clearest demonstration is to invoke directly or run a Notebook demo.

Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Inte
l)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import Pmw
>>> Pmw.Color.bordercolors(None, '#123456')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\python36_32\lib\site-packages\Pmw\Pmw_2_0_1\lib\PmwColor.py", line 36
2, in bordercolors
    '#%04x%04x%04x' % (lightRGB[0], lightRGB[1], lightRGB[2]),
Error:
TypeError: %x format: an integer is required, not float
Discussion
Thomas Holder

Thomas Holder - 2018-10-26
Patch #7 fixes this: https://sourceforge.net/p/pmw/patches/7/
Reply
#5
How would I do so (invoke directly)? What would the declaration look like?
Reply
#6
Sorry about last post. I did not see the patch at the end of Thomas' post. I went to SourceForge and downloaded fix. I do not know how to run it, and did not want to set up a new account just to ask. Can you please tell me how to open the downloaded file, or install?

Thanks,
MattSA
Reply
#7
Here's a calculator done using pmw and tkinter.
The post below shows what the GUI looks like
https://python-forum.io/Thread-Tkinter-V...675#pid675
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Adding New TAB to NoteBook Widget by Clicking Vicolas 0 2,583 Feb-15-2019, 06:03 PM
Last Post: Vicolas

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020