littlewhitecloud / TkTerminal

A terminal emulator widget written in Python using tkinter
MIT License
15 stars 2 forks source link

Bug fix & Improve #47

Open littlewhitecloud opened 1 year ago

littlewhitecloud commented 1 year ago

@Moosems This pr is yours now~ I am buckle up :D choose some issues you'd like to fix. (Maybe I will also fix some)

Todo list:

fix #43 fix #35 fix #36 fix #19 fix #27 fix #48 fix #49

Improve

Moosems commented 1 year ago

I'll work on it sometime tomorrow, please don't touch it in the meantime so I can figure out how to do some of these :).

littlewhitecloud commented 1 year ago

I'll work on it sometime tomorrow, please don't touch it in the meantime so I can figure out how to do some of these :).

LOL during this period, I will work on my new project: TranslucentTB (Yes a python version TranslucentTB) https://github.com/littlewhitecloud/TranslucentTB/

littlewhitecloud commented 1 year ago

LOL, its almost a week, do you find out something wrong? @Moosems

Moosems commented 1 year ago

LOL, my life has been so freaking crazy šŸ¤£. I had so many plans for this summer and a grand total of 0 are completed.

littlewhitecloud commented 1 year ago

@Moosems Will you still work on the pull request?

Moosems commented 1 year ago
Traceback (most recent call last):
  File "/Users/Moosems/Desktop/TkTerminal/test.py", line 1, in <module>
    from tktermwidget import Terminal
  File "/Users/Moosems/Desktop/TkTerminal/tktermwidget/__init__.py", line 7, in <module>
    from .style import *  # noqa: F401, F403
    ^^^^^^^^^^^^^^^^^^^^
  File "/Users/Moosems/Desktop/TkTerminal/tktermwidget/style.py", line 271, in <module>
    CUSTOM: dict[str] = load_style()
                        ^^^^^^^^^^^^
  File "/Users/Moosems/Desktop/TkTerminal/tktermwidget/style.py", line 72, in load_style
    with open(JSON_FILE, "r", encoding="utf-8") as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/Users/Moosems/Library/Caches/tktermwidget/styles.json'
littlewhitecloud commented 1 year ago
Traceback (most recent call last):
  File "/Users/Moosems/Desktop/TkTerminal/test.py", line 1, in <module>
    from tktermwidget import Terminal
  File "/Users/Moosems/Desktop/TkTerminal/tktermwidget/__init__.py", line 7, in <module>
    from .style import *  # noqa: F401, F403
    ^^^^^^^^^^^^^^^^^^^^
  File "/Users/Moosems/Desktop/TkTerminal/tktermwidget/style.py", line 271, in <module>
    CUSTOM: dict[str] = load_style()
                        ^^^^^^^^^^^^
  File "/Users/Moosems/Desktop/TkTerminal/tktermwidget/style.py", line 72, in load_style
    with open(JSON_FILE, "r", encoding="utf-8") as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/Users/Moosems/Library/Caches/tktermwidget/styles.json'

Sorry. I forget isort will move them in front of the checks.

littlewhitecloud commented 1 year ago

@Moosems Could you try to fix #43? I still donā€™t know how to fix.

Moosems commented 1 year ago

I'll give it a shot sometime soon.

littlewhitecloud commented 1 year ago

I'll give it a shot sometime soon.

Okay

littlewhitecloud commented 1 year ago

After I test #22, it doesn't freeze after input a bunch. (On Windows) result image args image https://github.com/littlewhitecloud/TkTerminal/issues/22#issuecomment-1603696271 Or can you ask someone who you know to test it on another platform? @Moosems

littlewhitecloud commented 1 year ago

LOL, @Moosems are you still on the car?

Moosems commented 1 year ago

Been traveling all month :). Two more weeks.

littlewhitecloud commented 1 year ago

Been traveling all month :). Two more weeks.

Sounds great!

Moosems commented 1 year ago

How's that other project of yours going?

littlewhitecloud commented 1 year ago

How's that other project of yours going?

Which project? ā€œCustomTkinterTitlebarā€ or ā€œTranslucenttbā€?

Moosems commented 1 year ago

The newest one :).

littlewhitecloud commented 1 year ago

The newest one :).

@Moosems You mean Translucenttb? Oh, I think it is almost finished. But still has some issues to fix. image image image image I also make something fun based on it:

https://github.com/littlewhitecloud/TkTerminal/assets/71159641/578f0b38-2a2e-400c-bb69-1df19e22f544

(LOL, just for fun)

littlewhitecloud commented 1 year ago

@Moosems I find out that why the program freeze. Maybe we can use threading (I am not good at it lol, but I will try to learn it)~

Moosems commented 1 year ago

Use an event_generate for "threads" as tkinter isn't thread safe.

littlewhitecloud commented 1 year ago

Use an event_generate for "threads" as tkinter isn't thread safe.

Can you give an example to show how to use event_generate()?

littlewhitecloud commented 1 year ago

It seems that tkinter is thread safe now...? (In the new version) I also find a closed issues talks about tkinter thread safe: https://github.com/python/cpython/issues/55286

Moosems commented 1 year ago

Can you give an example to show how to use event_generate()?

from tkinter import Tk, Button

root = Tk()

def threaded(_) -> None:
    print("Running in tandem with the main process")

root.bind("<<Thread>>", threaded)

Button(root, text="Thread", command=lambda: root.event_generate("<<Thread>>"))

root.mainloop()
Moosems commented 1 year ago

It seems that tkinter is thread safe now...? (In the new version)

I also find a closed issues talks about tkinter thread safe:

https://github.com/python/cpython/issues/55286

Read through it, it's not ;).

"all Tkinter access must be from the main thread (or more precisely, from the thread that calls the mainloop). Violating this is likely to cause nasty and mysterious symptoms such as freezes and core dumps."

Moosems commented 1 year ago

https://github.com/billyeatcookies/Biscuit/blob/main/biscuit/core/components/views/panel/terminal/terminal.py

Moosems commented 1 year ago

Biscuit does it anyway though :).

littlewhitecloud commented 1 year ago

https://github.com/billyeatcookies/Biscuit/blob/main/biscuit/core/components/views/panel/terminal/terminal.py

I actually looked at this document as well, and I was thinking what is superfluous with ours

Moosems commented 1 year ago

I might just "copy" parts ;).

littlewhitecloud commented 1 year ago

Bruh, It seems that I almost forget there is a pr.