This sounds like a really bad idea to me. After getting something
basic working (say, vertical or horizontal flow), the very next thing
you'll want to do is align elements -- say, placing check marks next
to menu items, or labels next to text boxes -- which is best done with
a tabular layout. The text layout module is really not set up for
tabular layout. It can do tab stops, but I think you'll find them
frustrating for this kind of thing.
Good luck with whichever path you choose -- GUI layout is a
surprisingly difficult problem (but one that can do with some
innovation!).
Alex.
Bad news on this front, my computer's power supply along with the hard
On May 7, 7:40 pm, dasacc22 <dasac...@gmail.com> wrote:
> > I figure that 80-90% of basic GUI needs can be satisfied by menus,
> > scrollbars, buttons, text fields, sliders, and checkboxes/radio boxes.
>
> I guess Im the 10% weirdo that needs tiered rotational dials, multi-
> layered drop boxes, and tool joints in my toolbox. Wish I had better
> names for what I am talking about, but crap.. I dont.
>
> Id still be curious to see a working example if you get around to
> posting one.
drive, losing my work on the GUI. It had been going all right up to
that point with a scrollable menu class that worked reasonably
speedily and a skinnable panel that would resize easily and looked
great on most backgrounds... But faced with recreating the work, I'm
not sure that overloading Document and IncrementalTextLayout are the
way to go. The main attraction of doing so was writing a GUI in a
very simple fashion, but I like the way Simplui does that more.
Compare Chrome code (or "line noise" as it's otherwise known") with:
Shoes.app { button "PUSH!" }
which (as the only code that's written) puts up a window with a button
labelled "PUSH!". It doesn't get much simpler than that. See also:
Shoes.app {
stack {
button "Mice"
button "Eagles"
button "Quail"
}
}
See http://shoooes.net/tutorial/ for some more examples.
"Simple is better than complex."
Richard
A saw your simplui examples, ive always eeked when seeing code like
that where its all one call. I can definately dig it, its just
something that urked me when i first started python for web
development and i saw these html helpers so can do things like HTML
(HEAD(TITLE()), BODY(P())) and "never write html again!"
I encourage anyone looking into developing new guis to look at Shoes
for Ruby. Implementing Chrome may seem like a really neat idea but
really, when you get down to it, XHTML/CSS/Javascript (or even
Pythonscript) is really quite cumbersome and yuck :)
Compare Chrome code (or "line noise" as it's otherwise known") with:
Shoes.app { button "PUSH!" }
which (as the only code that's written) puts up a window with a button
labelled "PUSH!". It doesn't get much simpler than that. See also:
Shoes.app {
stack {
button "Mice"
button "Eagles"
button "Quail"
}
}
See http://shoooes.net/tutorial/ for some more examples.
"Simple is better than complex."
On May 26, 6:08 pm, Tristam MacDonald <swiftco...@gmail.com> wrote:
> On the flip side, I need to rewrite the simplui layout system from theThat would indeed be impressive, but I'd be worried about how much
> ground up (shouldn't affect the public API), as my haphazard development
> left some conceptual issues, particularly with element resizing.
>
> I am also busy trying to embed an Awesomium build (i.e the Chrome rendering
> engine) inside pyglet, to offer a full HTML/CSS/JavaScript solution ;)
processing time it would suck away from the application. Would it be
a callout to a C++-based engine?
Wow, I hadn't seen NinePatch before. That's a really cool way of
encoding that information.
I wrote a basic pyglet-using implementation at
http://code.google.com/p/layer/source/browse/layer/layer/cirno.py,
which will cut up the image you give it based on NinePatch rules. You
can invoke it as a command line program with a filename and --write to
make it write out the cut PNGs, or just use it in your program and
pull the resulting images out of it. It's not very well tested, but it
works on a set of NinePatch tiles I made.
I'd like to also have some way to render it, but doing that in a
generally useful way is actually pretty tricky. You have to use an FBO
on a texture or a custom sprite class with independent X/Y scaling
(which is what I use). Or maybe someone else has a clever idea how to
do that without adding more dependencies.
Rendering a NinePatch is actually quite simple, you just draw 9 quads
with the appropriate texture coordinates. I hacked your NinePatch
code to demonstrate this:
http://code.google.com/p/pyglet/source/browse/trunk/experimental/ninepatch.py.
More work is needed to:
- Draw the image as part of a batch instead of in immediate mode
(very easy -- follow Sprite's example)
- Arbitrary number of stretchy regions, as allowed by Android
- Tiling the stretchy region instead of stretching it (I imagine this
would be more useful for decorative borders, etc).
Alex.
I should also have clarified that there's no need to save the patches
separately -- this method works by loading just the source image as a
texture. I had some trouble finding sample 9-patch images; there are
a couple here:
http://www.anddev.org/tutorial_buttons_with_niceley_stretched_background-t4369.html
Alex.
Ah, this is much smarter than what I was doing, and neatly solves the
drawing problem. Thanks! I'll see if I can find time to do the tiling
stuff tomorrow.
I saw the arbitrary number of stretchy regions was allowed by the
spec, but couldn't find any examples of it, and it's called
*nine*patch anyway. :)
I took "padding is optional" to mean that there need not be any black
marker in the lower/right section; however I assume the 1-pixel border
is mandatory.
> draw method probably needs to be changed a bit because taking the max
> means that it doesn't shrink (which i could only imagine it ought to)
The max() is there to ensure the 9-patch is never rendered smaller
than the original source image. Doing so causes artifacts (see for
yourself by commenting out the max and choosing a tiny font size).
> and when padding is None, the params passed to draw need to ?already
> know the size of the texture in relation to the label? (to move the
> x,y correctly for centering it).
The current code makes no attempt to center things. The two methods
can be used as:
- draw(x, y, width, height): Draw the entire 9-patch to fit within the
given area
- draw_around(x, y, width, height): Draw the 9-patch so that it
encloses the given area + padding.
Alex.