Re: Ncurses to GTK.



>The code is probably not abstracted finely enough to allow your
>library to be replaced and have the app 'work'.
>
>As for generating events... see the event loop, or threads. Probably
>it will be quite similar to the way your ncurses-based app works,
>only with some different sort of glue.

actually, ncurses->[some X Window toolkit] is frequently a LOT more
work than people anticipate. its possible to write apps with ncurses
that have a main event loop a lot like an X Window GUI would have. but
its also possible not to, or at least to only go 50% of the way
there. in such cases, the conversion can be quite painful. i know -
i've done it. keyboard handling also looks very different because X
Window tells you about keyboard presses and releases, whereas ncurses
only provides character input data. in some cases, this can be an
additional complexity, though in many instances, its nothing to worry
about at all.

>> > 1.) One thing I have been looking for is a window widget that would allow
>> > you to do something similar to this:
>> >   Window.Wprintf(1, 1, "THE NUMBER IS : %3.3d", myNumber);
>> > Where:
>> > 1,1 is x,y location.
>> > Window is the window.
>> > Wprintf similar to printf in c.

this is relatively easy to do, but the result probably won't look the
way you want it to without you understanding the many subtleties of
displaying text under X Window. there is no function like the one you
describe above, for example. 

>> > 2.) Also this is an industrial application where there are bunch of
>> > switches, air cylinders etc. wired into the PC.
>> > How would I generate an event if a switch is pressed.

i hope this isn't a port of the industrial robotic film sorter i wrote
for seattle filmworks 10 years ago :)

you need to hook a file descriptor for the device that receives data
from the sensors into the main event loop. when there is data to read,
a callback that you register will be called, and you can find out what
happened and change the state of the window(s) accordingly. see
gtk_input_add() and its ancestors in glib.

--p



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]