Perl's GUI - Perl

This is a discussion on Perl's GUI - Perl ; On Sun, 27 Aug 2006 13:02:13 GMT, zentara <zentara@highstream.net> wrote: >A few other comparisons bewtween Tk and Gtk2 (and WxWidgets built on >Gtk2). On an OT basis and on behalf of a friend of mine[*]: he's been having difficulties using ...

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 17 of 17

Perl's GUI

  1. Default Re: Perl's GUI

    On Sun, 27 Aug 2006 13:02:13 GMT, zentara <zentara@highstream.net>
    wrote:

    >A few other comparisons bewtween Tk and Gtk2 (and WxWidgets built on
    >Gtk2).


    On an OT basis and on behalf of a friend of mine[*]: he's been having
    difficulties using threads with Tk. I don't have experience with
    either so I couldn't really help him, but from posts both here and on
    PM I already knew about the possible issues, so I just reminded him of
    good ol' fork(). Now the question is: is Gtk2 thread safe? Which
    toolkit is, if any?

    [*] Really!


    Michele
    --
    {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
    (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
    ..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
    256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,

  2. Default Re: Perl's GUI


    Michele Dondi <bik.mido@tiscalinet.it> wrote in message-id:
    <d7o3f25kukj6tsihku7l09uf6a10i185gb@4ax.com>
    >
    >On Sun, 27 Aug 2006 13:02:13 GMT, zentara <zentara@highstream.net>
    >wrote:
    >
    >>A few other comparisons bewtween Tk and Gtk2 (and WxWidgets built on
    >>Gtk2).

    >
    >On an OT basis and on behalf of a friend of mine[*]: he's been having
    >difficulties using threads with Tk. I don't have experience with
    >either so I couldn't really help him, but from posts both here and on
    >PM I already knew about the possible issues, so I just reminded him of
    >good ol' fork(). Now the question is: is Gtk2 thread safe? Which
    >toolkit is, if any?
    >
    >
    >[*] Really!
    >
    >
    >Michele
    >--
    >{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
    >(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
    >.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
    >256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


    I belive much of the Tk thread issue has largely been solved.
    If you create the threads and shared variables prior to the Tk
    bits of your application; the threads behave quite nicely.

    I've begun re-writing some of my applications to use this trick,
    and have developed one from the ground up using this approach.
    The new threaded apps are quite reliable and seem fine.



  3. Default Re: Perl's GUI

    On 27 Aug 2006 20:19:36 +0200, Michele Dondi <bik.mido@tiscalinet.it>
    wrote:

    >On Sun, 27 Aug 2006 13:02:13 GMT, zentara <zentara@highstream.net>
    >wrote:
    >
    >>A few other comparisons bewtween Tk and Gtk2 (and WxWidgets built on
    >>Gtk2).

    >
    >On an OT basis and on behalf of a friend of mine[*]: he's been having
    >difficulties using threads with Tk. I don't have experience with
    >either so I couldn't really help him, but from posts both here and on
    >PM I already knew about the possible issues, so I just reminded him of
    >good ol' fork(). Now the question is: is Gtk2 thread safe? Which
    >toolkit is, if any?


    >Michele


    Well that is one of the good points about Gtk2 which I did not list.

    It does have a "thread-safety mechanism", which appeared releatively
    recently, around the 2.8 series of modules. Although it isn't perfect,
    it does show that the Gtk2 developers are aware of the problems and
    power of threads.


    What it does, is allow you to set ( see the thread_usage.pl in the
    examples subdir of the Perl/Gtk2 distro).

    use Gtk2 qw/-init -threads-init 1.050/;
    die "Glib::Object thread safetly failed"
    unless Glib::Object->set_threadsafe (TRUE);

    then in your threads, in the actual thread code block, you
    can do things like below, where you use enter and leave,
    to tell the main Gtk2 code that you are dipping into the thread and
    are going to modify a widget in the main thread.

    Gtk2::Gdk::Threads->enter;
    $progress->set_fraction ($i);
    $progress->set_text ($i * 100 .'%');
    Gtk2::Gdk::Threads->leave;
    # we're state employee's, so let's do some 'work'...
    sleep $sleep;


    This is a great advance, and similar code in Tk will result
    in the dreaded "free to wrong pool error" or a segfault.

    But as QoS pointed out, with proper precautions, threads can be
    successfully used with a main thread containing Tk code, but it is
    kind of a hack.

    So yes, Gtk2 is thread-safe (with some limitations). I've tested this
    quite a bit, and the Gtk2 thread-safety mechanism CAN be very finicky,
    but it's a start.



    --
    I'm not really a human, but I play one on earth.
    http://zentara.net/japh.html

  4. Default Re: Perl's GUI

    zentara wrote:

    > Why does making a textbox with a black background, (which is easier on
    > the eyes), make things hard for the user?


    There are "high contrast" themes to make things easier on the
    eyes of those who need it. Selecting such a theme makes all
    textboxes "easier on the eyes", not just one or two.
    -Joe

  5. Default Re: Perl's GUI

    zentara wrote:
    > The biggest complaint about Tk, is that it is a big hodgepodge
    > of independent widgets, whearas Gtk2 is all based on Glib objects.
    > This dosn't sound too important yet, but it becomes so when you
    > try to sub-class objects and control signalling between them.


    I have very few issues subclassing Tk widgets in either pure Tcl (using
    snit) or in Perl Tkx.

    > Now for the bad news. Perl/Gtk2 can make it very difficult to do
    > what is simple in Tk. The most obvious thing is colorization of
    > widgets. Gtk2 has a powerful "theme" system, so you can make all your
    > apps look like your other Gtk2 apps like mozilla. BUT, that same theme
    > system, makes it quite difficult to give custom colors and fonts to
    > individual widgets.
    > Tk dosn't have that problem.


    Yes and no. You can give yourself this problem in Tk as well
    (specifically for perl users, with Tcl::Tk or Tkx). Tk has the tile
    themed widget extension which provides access to the newer themed native
    widgets of OS X and Windows (and even has an extension on itself that
    will use the Qt theme engine on unix). Using those of course creates
    the same limitations that you see in Gtk2. However, you can always fall
    back on the classic Tk widgets for one-offs or other special cases.

    --

    Jeff Hobbs, The Tk Guy, http://www.activestate.com/

  6. Default Re: Perl's GUI

    On Tue, 29 Aug 2006 20:35:53 -0700, Jeff Hobbs <jeffh@activestate.com>
    wrote:

    >> Now for the bad news. Perl/Gtk2 can make it very difficult to do
    >> what is simple in Tk. The most obvious thing is colorization of
    >> widgets. Gtk2 has a powerful "theme" system, so you can make all your
    >> apps look like your other Gtk2 apps like mozilla. BUT, that same theme
    >> system, makes it quite difficult to give custom colors and fonts to
    >> individual widgets.
    >> Tk dosn't have that problem.

    >
    >Yes and no. You can give yourself this problem in Tk as well
    >(specifically for perl users, with Tcl::Tk or Tkx). Tk has the tile
    >themed widget extension which provides access to the newer themed native
    >widgets of OS X and Windows (and even has an extension on itself that
    >will use the Qt theme engine on unix). Using those of course creates
    >the same limitations that you see in Gtk2. However, you can always fall
    >back on the classic Tk widgets for one-offs or other special cases.


    Maybe it's my lack of experience as a language developer, but why isn't
    it setup so that theme settings are automatically overridden, if a
    widget specifies a customization option in it's new declaration.

    For instance, if I do
    $widget = $mw->new( -bg => 'skyblue' );
    it should automatically override the theme.

    As it is now, in Gtk2 anyways, I need to find the EXACT (and poorly
    documented syntax) for the theme settings for that particular widget.
    Override in a local theme file (yes it has to be from disk file) that
    particular setting by explicitly nullifying it. THEN cross my fingers
    and hope the new setting takes. It is hours and hours of B.S., just
    to change a simple widget setting.

    Just blowing off pent up steam over this...................... :-)


    --
    I'm not really a human, but I play one on earth.
    http://zentara.net/japh.html

  7. Default Re: Perl's GUI

    zentara wrote:
    > On Tue, 29 Aug 2006 20:35:53 -0700, Jeff Hobbs <jeffh@activestate.com>
    > wrote:
    >
    >>> Now for the bad news. Perl/Gtk2 can make it very difficult to do
    >>> what is simple in Tk. The most obvious thing is colorization of
    >>> widgets. Gtk2 has a powerful "theme" system, so you can make all your
    >>> apps look like your other Gtk2 apps like mozilla. BUT, that same theme
    >>> system, makes it quite difficult to give custom colors and fonts to
    >>> individual widgets.
    >>> Tk dosn't have that problem.

    >> Yes and no. You can give yourself this problem in Tk as well
    >> (specifically for perl users, with Tcl::Tk or Tkx). Tk has the tile
    >> themed widget extension which provides access to the newer themed native
    >> widgets of OS X and Windows (and even has an extension on itself that
    >> will use the Qt theme engine on unix). Using those of course creates
    >> the same limitations that you see in Gtk2. However, you can always fall
    >> back on the classic Tk widgets for one-offs or other special cases.

    >
    > Maybe it's my lack of experience as a language developer, but why isn't
    > it setup so that theme settings are automatically overridden, if a
    > widget specifies a customization option in it's new declaration.
    >
    > For instance, if I do
    > $widget = $mw->new( -bg => 'skyblue' );
    > it should automatically override the theme.


    Actually, some of the Tk themed widgets do allow that, but not all. It
    depends on how "special purpose" the widget was determined to be. For
    example, the themed label widget allows fg/bg color changes, but the
    themed entry doesn't, while the themed frame allows relief/bd changes,
    but the themed button doesn't. Of course, you can create special styles
    based on the original. The following sets the invalid state of themed
    entries and labels to use a red foreground in Tkx:

    # Make invalid state entry/label widget change color scheme
    Tkx::style(map => "TEntry", -foreground => [invalid => "red"],
    -fieldbackground => [invalid => "yellow"]);
    Tkx::style(map => "TLabel", -foreground => [invalid => "red"]);

    The state invalid can be controlled automatically through the entry
    widget's built-in validation mechanism, or the state method on the
    widget. Modifying an existing style works like so:

    Tkx::style(default => 'Slim.Toolbutton', -padding => 2);

    which just changes the padding of the regular Toolbutton style, and you
    would apply like so:

    my $slimbtn = $mw->new_ttk__button(-style => "Slim.Toolbutton");

    so it's probably still easier than other toolkits, but still "different"
    from classic Tk.

    --

    Jeff Hobbs, The Tk Guy, http://www.activestate.com/

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2

Similar Threads

  1. Equivalent of perl's Pod::Usage?
    By Application Development in forum Python
    Replies: 8
    Last Post: 12-13-2007, 05:19 PM
  2. regex that is equivalent to perl's syntax
    By Application Development in forum Python
    Replies: 2
    Last Post: 11-12-2007, 10:51 AM
  3. Python equivalent of Perl's $/
    By Application Development in forum Python
    Replies: 7
    Last Post: 08-20-2007, 05:02 PM
  4. perl's BOP OLTP server vs smalltalk
    By Application Development in forum Smalltalk
    Replies: 0
    Last Post: 07-12-2006, 05:47 PM
  5. Embedded perl's compiler messages
    By Application Development in forum Perl
    Replies: 0
    Last Post: 07-15-2004, 07:26 PM