flexxui / flexx

Write desktop and web apps in pure Python
http://flexx.readthedocs.io
BSD 2-Clause "Simplified" License
3.25k stars 258 forks source link

MenuWidget implementation #315

Open JohnLunzer opened 7 years ago

JohnLunzer commented 7 years ago

The background for this enhancement request is that there is interest from a not-well-known but venerable python IDE (for which I am a minor contributor) to implement a browser-based GUI. Currently it uses PyQt as its GUI framework. Flexx is an exciting prospect for Leo as it represents an opportunity to bring Leo to a new audience.

I think the two biggest barriers right now are a lack of MenuWidget and a lack of a code editor widget.

Phosphor has a built-in Menu class. Additionally Phosphor provides an example of a CodeMirror based code editor widget being used with the Menu widget.

I thought I read somewhere that Pyzo plans an eventual move over to Flexx. Am I imagining that?

@almarklein, the fact that this can even be considered and discussed is a testament to the amazing work you've done on Flexx.

Korijn commented 7 years ago

Personally, I've found the Label widget to be a nice and simple starting point for writing your own widgets that wrap around something else. Can't wait to see what Almar thinks of this cool suggestion!

almarklein commented 7 years ago

Thanks @JohnLunzer.

Flexx should definitely have a MenuWidget. Since Phosphor already has it, I don't expect it to be that much work, I've simple never needed it yet.

I also like the idea of an editor widget, and even have a branch with a start of one based on canvas. CodeMirror is also used in JupyterLab. I have not looked at it that much yet, but my impression is that its too limited for a serious IDE. Writing one from scratch is a pretty big task though! Thinking out loud here, maybe a better editor component for JLab should be written in Flexx ...

I thought I read somewhere that Pyzo plans an eventual move over to Flexx. Am I imagining that?

Kind of. Two years ago I was planning on rewriting Pyzo, and call it Zoof (ideas are on this outdated website). Travis Oliphant suggested it would be awesome if that could run in a browser, and that's how Flexx was born. At that time Pyzo was still called IEP and Pyzo was a distro; Zoof would be a combination of sorts. Because building Flexx was not done in 6 months :P, I started bringing some ideas of Zoof to the existing tools, the most prominent being merging the two and calling it Pyzo (its confusing, I know).

For the past few months I've been working with Continuum to make Flexx work on JLab so people can extend JLab by writing Python. I plan to try to implement the ideas that I had for Zoof in JLab and see if I can turn it into what I envisioned with Zoof.

Leo is cool; it offers a very interesting concept. I've tried it a few times, but could not get used to it ... though maybe I did not try it long enough.

JohnLunzer commented 7 years ago

@almarklein I agree that writing a code editor element is serious work. Going on CodeMirror's site and looking at the features/demos it looks to be suitable as an easy to implement placeholder, at the very least, until a more robust solution can be determined. It would be nice that have something in place for people (like myself) to start playing with and trying to build a GUI around. Better to have something (imperfect) than nothing.

Thanks for your thoughts on Zoof (Pyzo). It's exciting to think about the future of Python-based IDEs.

Leo is hard to get used to. As an IDE it's missing many features (which, in it's defense, I should be adding as plugins) but now I can't live without the inherent structure that Leo injects into my coding, I often get lost without it.

almarklein commented 7 years ago

I suspect it wont be that hard to make a widget that wraps a codemirror element.

almarklein commented 7 years ago

I suspect it wont be that hard to make a widget that wraps a codemirror element.

No, not that hard: #323

JohnLunzer commented 7 years ago

Additionally, an important component of desktop applications that is part of Phosphor but not implemented in Flexx is the Menu item which allows desktop style right click context menus. The phosphor Menu object appears to be a prerequisite for creating MenuBar items so probably Menu will come in anyway, but I wanted to be as explicit as possible.

I almost feel like this issue should be renamed to something "UI elements supporting desktop style applications".

I still have a high interest in using Flexx for desktop style applications, I'm looking forward to the menu widgets.

almarklein commented 7 years ago

Yes, I believe the Phosphor code for Menu is there, it just needs to be wrapped. Time is a scarce resource though ;) I will remove the reference to the editor, to let this issue represent the Menu feature.

JohnLunzer commented 6 years ago

It's been a year and I just wanted to check in.

I know it might seem silly but the lack of the MenuWidget is one of the primary reasons I do not consider Flexx more often for my desktop apps. Well... one of the hallmarks of the desktop app is menu bar.

almarklein commented 6 years ago

@JohnLunzer Thanks for the heads-up! This has not been a priority so far. Now that we're nearing a release, its not unlikely that I/we will be building more stuff with Flexx, and might run into the need ourselves... but don't expect it next week :)

JohnLunzer commented 6 years ago

Haha, nothing that urgent. My intention was a gentle reminder ;)

huangxin168 commented 2 years ago

Haha, nothing that urgent. My intention was a gentle reminder ;)

context menu is the major issue that I think about wether to use flex...