Open redapple0204 opened 6 years ago
I think that the number order is correct here, but the characters aren't fixed width so they are not lining up with the headings. The 1st of July 2017 is a Sunday so should be on a row by itself exactly like that. If you want to confirm this, just printing that calendar should give you the same order wherever you run it.
The width behaviour is a bit strange - when you use a codebox, you should be getting fixed width font, so a 'wide' character like 'w' gets the same width as a narrow character like 'l' on screen.
Could you run the codebox in both places (mint and wine) and see whether a sample string like: "123abcwl0" displays as fixed-width or not?
The underlying problem may be to do with getting a fixed width font on mint, but I'd like to confirm that we're looking in the right place before we dig too deep...
@zadacka humm,so do you think I need to use a monospaced font in easygui?
The codebox should already be using a monospaced font, but it looks like this never actually gets applied.
@redapple0204 could you help me to confirm this, please? Specifically, could you go into easygui/boxes/text_box.py
on your Mint box and add change self.messageArea
to the following in line 456:
self.messageArea = tk.Text(
self.msgFrame,
width=self.width_in_chars,
state=tk.DISABLED,
padx=(global_state.default_hpad_in_chars) *
self.calc_character_width(),
pady=global_state.default_hpad_in_chars *
self.calc_character_width(),
wrap=tk.WORD,
font=tk_Font.nametofont("TkFixedFont") # this is the new bit
)
Then run your example. The change should then force the message area to display with a fixed width font, and you should see what you want.
It looks like the box currently picks up the default system font; if that happens to be monospace then everything displays correctly, and if it is not monospace then the widths all vary.
Unfortunately, it is tricky to decide what the 'correct' behaviour should be. Some people might want to use variable width text in the message, whilst other people may want fixed width.
Let's start with the basics - trying the above to confirm that it addresses the behaviour you are experiencing. Once we've got that, then we can decide how to proceed...
@zadacka I tried to modify this file and then run my python program, but it doesn't work. After modifying this file,I also tried modifying the fonts in boxes\global_state.py to be set to a monospaced font, but it doesn't work either. After modifying this file,I also tried modifying the font of the entire system to become a monospaced font, but it didn't work either.
It should display correctly if you can set the font to a fixed width-font. Not EasyGUI code, but demonstrates the problem & solution. If the displayed font isn't fixed width.
Setting the font to Courier New fixes the problem
Sample code that made the screen shots:
import PySimpleGUI as sg, calendar
cal7 = calendar.month(2018, 7)
sg.MsgBox(cal7)
sg.MsgBox(cal7, font=('Courier New', 12))
@MikeTheWatchGuy Thanks a lot,I will try it later.
@redapple0204 - did this work out for you?
I am trying to use codebox to display a calendar in easygui in python3.4
My code is as follows
But its display results are as follows
You can see,these numbers are out of order.
But something interesting,I run this code with wine's python 3.4, the display is correct.
My OS:Linux mint 17.3(mate)
python version:3.4.3.
easygui version: (0.98.1)
How should I solve this problem? Thans for your help