Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Force Plot Size + Tkinter Integration #33

Closed
gregwa1953 opened this issue Jul 28, 2021 · 12 comments
Closed

Feature Request: Force Plot Size + Tkinter Integration #33

gregwa1953 opened this issue Jul 28, 2021 · 12 comments

Comments

@gregwa1953
Copy link

First, I love the program!

I have been able to use plotext to plot to a tkinter text widget. It works well, but is totally dependent on the terminal size that the user happens to be using at runtime.

Would it be possible to add a flag to ignore the actual terminal size and force it to, let's say 80x24, so that when the plot is generated (hidden and saved to file) can be sent directly to the tkinter text widget?

Thank you in advance for your consideration.
Greg

@piccolomo
Copy link
Owner

piccolomo commented Aug 6, 2021

Hi @gregwa1953 ,

Thanks for the idea and I will definitively work on that. I was thinking of a function as plt.forcesize() or an option of the plt.figsize() function.

I will keep updated.

All the best
Savino

P.S. The idea of having a tkinter text widget sounds great. If you want to share it perhaps drop a code and an image. thanks

@gregwa1953
Copy link
Author

I really appreciate it.
I'll try to get an image and some sample code up in the next day or two.

Thank you again for the help and the great project.

@gregwa1953
Copy link
Author

I've updated a demo that I created using PAGE, a GUI designer for Python using Tkinter.

Hays County Texas Covid-19 Confirmed Cases 6-27-2021 to 7-27-2021_001

I've included all three files generated by PAGE (The actual tcl file from the designer and the two Python files that age generated by PAGE.) plus this readme and a screen capture of the actual program in operation. It is a very basic demo program, simply designed to show how easy it is to place a plotext saved plot figure file into a scrolled Tkinter Text box.

The file plotextTest2.py is the actual GUI file that is created by PAGE and should not be modified by hand. The plotextTest2_support.py file is where all the code goes. PAGE creates this file as well and includes all start up code and all callbacks that are needed to get started. I have commented the "_support.py" file fairly well.

The attached zip file contains a readme.md file, the screen image above and the source files. Please see the readme.md file within the zip for more information. It actually took me more time to generate the covid-19 data list than it did to create the GUI and write the rest of the code. 90% of all the work was done by PAGE.

The program uses a ScrolledText widget, that comes with PAGE, but could easily be replaced with a "standard" Tk/Tkinter Text widget. I chose to use the ScrolledText widget to ensure that regardless of the terminal size, the plot would show on the form.

Thank you again!,

Greg Walters

plotext demo Page.zip

@piccolomo
Copy link
Owner

Hi @gregwa1953 ,

the new 4.0.0 version of plotext is now available on github and pypi. :-)

I have credited you for the idea regarding forcing the plot size beyond the terminal: in this version the function that does it is actually plt.limit_size(). Let me know if you like it or what you think of it! 👍

Regarding the tkinter plugin: it is a great idea! I will definitively consider it for next version. 💯

Thanks and all the best,
Savino

@piccolomo piccolomo changed the title Force terminal size Feature Request: Force Plot Size beyond Terminal Dec 12, 2021
@piccolomo
Copy link
Owner

piccolomo commented Dec 18, 2021

Hi @gregwa1953,

not sure if you are still interested but i have created a page guide for the integration of plotext and tkinter available here.

The new plotext version 4.1.3 is available on github and pypi.

Thanks and all the best,
Savino

@gregwa1953
Copy link
Author

gregwa1953 commented Dec 18, 2021 via email

@piccolomo
Copy link
Owner

piccolomo commented Dec 18, 2021 via email

@gregwa1953
Copy link
Author

Good morning.
I've been ill the last two days, so my brain rebelled to trying to learn anything new. However, this morning, I felt a little bit better and was able to get my head around the new syntax and the plotsize parameter and the usage of limitsize.

I still have a little bit left to really get my stuff together, but it works well. I'm VERY impressed.
THANK YOU SO MUCH.
Plotext 4 13 Demo_001

Don (the author of PAGE) and I are working very hard on the next release of PAGE and this demo will be part of the distribution.

Once that happens, I'll provide you with a new demo program.

@piccolomo
Copy link
Owner

piccolomo commented Dec 20, 2021

Hi @gregwa1953, thanks for the update and glad you enjoyed the initial result.

Just reminding that in your previous code, you were able to print in colors and with high resolution markers. Not sure how you managed that, as I didn't seem to find a way. It would be cool to see those features in your next demo, if they are easy to integrate and you are available.

One thing this integration could be useful at, for example, is to plot really big images or plots, which is not possible on terminal due to its more limited size. A button to save the image and plot as html, could also be an idea .

Thanks a lot for your interest and take care!

P.s. I could find the page package, you were referring.

@piccolomo piccolomo changed the title Feature Request: Force Plot Size beyond Terminal Feature Request: Force Plot Size + Tkinter Integration Dec 21, 2021
@gregwa1953
Copy link
Author

Actually, the code was only able to show the plot in monochrome, but the plot itself was saved as a colour plot. I am, however, trying to figure out a way to provide colour support. At this point, my demo program, like yours, uses a tk.Label widget to show the plot, which can not provide colour support.

All that having been said, I've taken my demo program from the new version of PAGE (which hasn't been released yet) to the current version (6.2). The attached zip file contains the two Python files and the .tcl file for PAGE itself.
Plotext_4.1.3_PAGEV6.zip

Here are a few screenshots...

Plotext 4 1 3 Demo_001

Plotext 4 1 3 Demo_002

Plotext 4 1 3 Demo_003

I truly hope that this demo helps to support your fantastic package!

I'll notify you if I can crack the colour thing.

Greg

@piccolomo
Copy link
Owner

Hi @gregwa1953,

I did it! Thanks to your valuable inputs and encouragements, I arrived to a satisfactory results, shown here.

What do you think? :-)

Thanks,
Savino

@gregwa1953
Copy link
Author

gregwa1953 commented Dec 23, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants