Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > how do I add a C widget to Ruby/Tk?

Reply
Thread Tools

how do I add a C widget to Ruby/Tk?

 
 
Bill Paxton
Guest
Posts: n/a
 
      01-09-2005
--B_3188107978_10962276
Content-type: text/plain; charset="ISO-8859-1"
Content-transfer-encoding: quoted-printable

I have an existing Tcl/Tk widget written in C that I=B9d like to port to
Ruby/Tk. The Lidie & Walsh book on Perl/Tk is helpful, but it doesn=B9t quit=
e
supply enough information. For example, it contains a call on
=B3Lang_CreateWidget=B2 that needs to be mapped to something for Ruby/Tk, but
what might that be?

Does anyone have a working example of a C widget done in Ruby/Tk? Could yo=
u
please share the secrets?

Thanks,
Bill Paxton


--B_3188107978_10962276--


 
Reply With Quote
 
 
 
 
Hidetoshi NAGAI
Guest
Posts: n/a
 
      01-10-2005
Hi,

From: Bill Paxton <(E-Mail Removed)>
Subject: how do I add a C widget to Ruby/Tk?
Date: Mon, 10 Jan 2005 02:33:05 +0900
Message-ID: <BE06AACA.1C67%(E-Mail Removed)>
> I have an existing Tcl/Tk widget written in C that Iąd like to port to
> Ruby/Tk.


Please use your widget as it is.
Ruby/Tk (tcltklib) uses standard Tcl/Tk libraries.
If your wish (which uses same Tcl/Tk libraries) can load your widget
library, Ruby/Tk can load the widget library. For exapmle,

<Ruby/Tk method call> <call on Tcl/Tk>
Tk.load_cmd_on_ip(tk_cmd) --> auto_load tk_cmd
Tk.load_tclscript(file, enc=nil) --> source ?-encoding enc? file
Tk.load_tcllibrary(file, pkg=None, --> load file ?pkg? ?interp?
interp=None)

Tk.tk_call(cmd, arg, ... ) --> cmd arg ...
Tk.ip_eval(script) --> (eval "script" on Tcl/Tk ip)

Probably, you'll be able to load your widget library by
Tk.load_tcllibrary('your widget library').
After that, you can create and control your widgets by Tk.tk_call().

If you want create a class for your widget,
it is better the class is a sub-class of TkWindow class.
When the create command of your widget is "xxx path ??-opt val? ...?",
minimum definition for your widget class is the following.
----------------------------------------------------------
class YOUR_WIDGET < TkWindow
TkCommandNames = ['xxx'.freeze].freeze

WidgetClassName = 'Xxx' # if needed
WidgetClassNames[WidgetClassName] = self # if needed

# define instance methods for your widget class

end
----------------------------------------------------------
Then, you'll be able to create your widget by
----------------------------------------------------------
YOUR_WIDGET.new(parent, optkeys){ ... }
----------------------------------------------------------
like as other standard widgets.
--
Hidetoshi NAGAI ((E-Mail Removed))



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Re: Tkinter.event.widget: handler gets name instead of widget. Terry Reedy Python 15 07-16-2012 10:32 AM
Re: Tkinter.event.widget: handler gets name instead of widget. Frederic Rentsch Python 0 07-09-2012 08:39 PM
Tkinter.event.widget: handler gets name instead of widget. Frederic Rentsch Python 0 07-08-2012 09:19 PM
user interface widget: ordered selection list: do any UI library has this widget? zhangweiwu@realss.com Javascript 0 10-10-2006 01:02 AM



Advertisments