Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Print Console in TextView or ScrollView
-
@JonB Thanks Jon, I was about to use stash, but I wanted to have some graphics and sound sort of like the Commodore 64 Fahrenheit 451 text adventure. https://www.youtube.com/watch?v=OGu_Urn4hek
-
Here is a script to switch between console and text view. I hope it is useful.
https://gist.github.com/balachandrana/6c8617382079e4486b12a4dd35f5c8c5
-
If you just want to append text to a textview, just append to
text
(with tv.text +='You Are in an empty room.\n'). You have to scroll the tv yourself, this was an annoying bit in early versions of stash. Of course you could always iust use stash.terminal, without the stash executable.Those old style games i think has to basically manage their own graphics, including drawing text where it belonged...
I started porting an apple 2 emulator , and had to implement a screen.py... which basically allows writing bits to a numpy array, and then updates an imageview. The screen code itself was reasonably fast, though of course pretty low resolution.
-
Thanks guys! Both these ideas worked great!
-
Hi, I’m also a novice trying to make a UI for a text-y thing I started on in the console: https://github.com/weevil/adventurers_guild
Doesn’t PyUI depend on pygame to work? Doesn’t that make it unusable with Pythonista? -
@wiley The
ui
module is based on the iOSUIKit
framework, it has nothing to do with pygame. It's also specific to Pythonista, there's no way to use it on regular computers, since the underlying framework only exists on iOS. -
Thank you!
Is there a comparable simple ui module that works both in and out of pythonista? I had looked at pyglet but it requires pygame. I'd like to be able to work in pythonista but still have the program run elsewhere. I only need a very minimal UI... basically just a box to dump text in and a button or two to refresh it.
-
-
I had to use a more portable ui module like I mentioned but I’m playing with pythonista‘ ui module and it’s really great! I can’t believe it’s got its own graphical editor. Is there a code example somewhere on how to populate the scroll view element? I’m not sure how to get output into it.
-
-
Even in the scrollview example in there I don't see an attribute for like, .text or .content... what am I missing?
-
Scrollviews are just container views that contain subviews.
You use add_subview to add stuff to a scroll view (usually will be a single view that is larger than the scrollview.
You then use content_size to set the scrollable region -- usually would be the size of your subview. When content_size is larger than the scrollview frame, it will allow scrolling.Note that both TableView and TextView are actually subclasses of ScrollView, so if you are just doing tabular or textual work, you don't need scrollview per se, but can still implement some of the delegate methods.
-
Ah! Thank you!