I''ve been trying to figure out the best method for generating GUI''s with Ruby. I ended up using DialogBlock because it seems like the fastest way. But not I have to work backwards and have not done this before. How do I go from the file I generate in DialogBlock to a code in Ruby? -- Posted via http://www.ruby-forum.com/.
Joshua Lefkowitz wrote:> I''ve been trying to figure out the best method for generating GUI''s with > Ruby. I ended up using DialogBlock because it seems like the fastest > way. But not I have to work backwards and have not done this before. > How do I go from the file I generate in DialogBlock to a code in Ruby? >The wxruby example samples/xrc/xrc_sample.rb shows how to load an XRC-based layout into a wxRuby program. To save time, I also recommend that you have a look at the tool ''xrcise''. This automatically creates ruby code to load XRC layouts and link to specific controls within the XML file: http://wxruby.rubyforge.org/wiki/wiki.pl?UsingXRCise alex
Alex Fenton wrote:> The wxruby example samples/xrc/xrc_sample.rb shows how to load an > XRC-based layout into a wxRuby program. > > To save time, I also recommend that you have a look at the tool > ''xrcise''. > alexThanks for your help. I am slowly learning how to do this. I followed your suggestions. I am able to generate the XRC file from DialogBLock. Then, I am able to generate the my_frame.rb file. But, when I try to integrate it by using the code posted on the tutorial in the creating a code in SciTE. I get the following syntax error in two lines of the source: syntax error, unexpected ''\n'', expecting tCOLON2 or ''['' or ''.'' I tried figuring out how to change the code myself to resolve this error, but I''m just not good enough...yet -- Posted via http://www.ruby-forum.com/.
Joshua Lefkowitz wrote:> I get the following syntax error in two > lines of the source: > > syntax error, unexpected ''\n'', expecting tCOLON2 or ''['' or ''.'' > >Please could you post your XRC file and the generated code. Thanks. alex
> Joshua Lefkowitz wrote: >> syntax error, unexpected ''\n'', expecting tCOLON2 or ''['' or ''.'' > Please could you post your XRC file and the generated code. Thanks.Alex, here''s the code (from the XRCise tutorial) --------------- require ''wx'' # load in the generated code require ''my_frame'' # Mix-in for a Wx::TextCtrl module CaseChangeTextCtrl? # convert all the text in the control to upper case def upcase! self.value = self.value.upcase end # convert all the text in the control to lower case def downcase! self.value = self.value.downcase end end # Inherit from the generated base class and set up event handlers class CaseChangeFrame? < TextFrameBase? def initialize super evt_button(upper_bt) { text_box.upcase! } evt_button(lower_bt) { text_box.downcase! } end end # Run the class Wx::App.run do CaseChangeFrame?.new.show end ------------ Josh -- Posted via http://www.ruby-forum.com/.
Joshua Lefkowitz wrote:> Alex, here''s the code (from the XRCise tutorial) > > --------------- > > require ''wx'' > # load in the generated code > require ''my_frame'' > > # Mix-in for a Wx::TextCtrl > module CaseChangeTextCtrl?Ah, sorry, looks like the wiki has mangled some of the ruby code by adding ? - there shouldn''t be one here. I''ve corrected the formatting on the wiki, can you try to copy and paste again please? thanks alex
>> require ''wx'' >> # load in the generated code >> require ''my_frame'' >> >> # Mix-in for a Wx::TextCtrl >> module CaseChangeTextCtrl? > > Ah, sorry, looks like the wiki has mangled some of the ruby code by > adding ? - there shouldn''t be one here. I''ve corrected the formatting on > the wiki, can you try to copy and paste again please? > > thanks > alexI gave it another shot and it still wasn''t working. So, I tried removing all of the ''?'' characters from the ruby source code. This worked, but I don''t see any buttons. My question is, the wiki page shows ''?'' characters for working in the DialogBlock and for the ruby source. Perhaps just clarifying where a ''?'' does and doesn''t belong will fix everything. Still, for a really green programmer, just getting it to work at all was very satisfying. If I complete this project, I hope to have something to give back to the open source community. Thanks! -- Posted via http://www.ruby-forum.com/.
Hi, On 06.03.2008, at 23:22, Joshua Lefkowitz wrote:> I gave it another shot and it still wasn''t working. So, I tried > removing all of the ''?'' characters from the ruby source code. This > worked, but I don''t see any buttons. My question is, the wiki page > shows ''?'' characters for working in the DialogBlock and for the ruby > source. Perhaps just clarifying where a ''?'' does and doesn''t belong > will fix everything.? is just a wiki link for creating a new page for CaseChangeTextCtrl. The wiki editor has to quote the wiki-text. If it''s a TWiki then you should quote it with ''!'': !CaseChangeTextCtrl (IIRC). hth. regards, sandor --
Joshua Lefkowitz wrote:> I gave it another shot and it still wasn''t working. So, I tried > removing all of the ''?'' characters from the ruby source code. This > worked, but I don''t see any buttons. My question is, the wiki page > shows ''?'' characters for working in the DialogBlock and for the ruby > source. Perhaps just clarifying where a ''?'' does and doesn''t belong > will fix everything.REalised I hadn''t saved the changes to the wiki page. The source code should be correct now without ''?'' alex
Alex Fenton wrote:> Joshua Lefkowitz wrote: >> I gave it another shot and it still wasn''t working. So, I tried >> removing all of the ''?'' characters from the ruby source code. This >> worked, but I don''t see any buttons. My question is, the wiki page >> shows ''?'' characters for working in the DialogBlock and for the ruby >> source. Perhaps just clarifying where a ''?'' does and doesn''t belong >> will fix everything. > REalised I hadn''t saved the changes to the wiki page. The source code > should be correct now without ''?'' > > alexThe code works, but I still do not see the buttons in the window that I produce. I followed the wiki as instructed from start to finish. Is there some functionality I was supposed to give to the buttons that perhaps I didn''t? Attachments: http://www.ruby-forum.com/attachment/1523/frame.xrc -- Posted via http://www.ruby-forum.com/.
Joshua Lefkowitz wrote:> The code works, but I still do not see the buttons in the window that I > produce. I followed the wiki as instructed from start to finish. Is > there some functionality I was supposed to give to the buttons that > perhaps I didn''t?Your buttons and the textctrl need to be arranged in a Sizer. In DialogBlocks you should see in the palette of addable elements a "Sizers" tab. Add a vertical sizer to the main frame. Then, in order, add the TextCtrl and the two buttons to it. I guess the tutorial should be more explicit about this but I''d think that the result you have at the moment doesn''t look right in the preview shown in DialogBlocks? alex
Alex Fenton wrote:> Joshua Lefkowitz wrote: >> The code works, but I still do not see the buttons in the window that I >> produce. I followed the wiki as instructed from start to finish. Is >> there some functionality I was supposed to give to the buttons that >> perhaps I didn''t? > Your buttons and the textctrl need to be arranged in a Sizer. In > DialogBlocks you should see in the palette of addable elements a > "Sizers" tab. Add a vertical sizer to the main frame. Then, in order, > add the TextCtrl and the two buttons to it. > > I guess the tutorial should be more explicit about this but I''d think > that the result you have at the moment doesn''t look right in the preview > shown in DialogBlocks? > > alexI''ll play with it and I think I can figure it out from what you wrote. I think these types of problems--where you''re not explicit about something--is more an issue for people like me who are really new to programming and trying to teach themselves everything. People who have experience with programming probably would have picked up on this issue. I''ll let you know the results. Thanks. -- Posted via http://www.ruby-forum.com/.
>> Your buttons and the textctrl need to be arranged in a Sizer. In >> DialogBlocks you should see in the palette of addable elements a >> "Sizers" tab. Add a vertical sizer to the main frame. Then, in order, >> add the TextCtrl and the two buttons to it.SUCCESS! Now, I just have to understand it all and get to my own code. Thanks for your help. I was just about ready to throw in the towel. Help and OCD prevail. -- Posted via http://www.ruby-forum.com/.
Joshua Lefkowitz wrote:> SUCCESS! > > Now, I just have to understand it all and get to my own code. > > Thanks for your help. I was just about ready to throw in the towel. >Great, glad it worked out. Feel free to ask for help; this is a friendly list for people with all levels of experience Good luck alex
Alex Fenton wrote:> Joshua Lefkowitz wrote: >> SUCCESS! >> >> Now, I just have to understand it all and get to my own code. >> >> Thanks for your help. I was just about ready to throw in the towel. >> > Great, glad it worked out. Feel free to ask for help; this is a friendly > list for people with all levels of experience > > Good luck > alexI tried to move on to apply what I learned and make my own simple application. I started off more simple than the XRCise tutorial example, just creating a frame through DialogBlock, then applied XRCise. When I get to writing the ruby source code that mixes in the ruby class file generated from XRCise, I get nowhere. I''m thinking that I''m not just going to be able to pick this up as easily as I hoped and was wondering if there are particular books (or chapters of books) or websites I should be looking at to learn the basics--with respect to GUI. I have the "pickaxe", the Ruby Way (and a couple of others), and I''ve been all over the web, so I have a general feel for all the info that''s out there--there''s so much out there, I''m not sure what to focus on at this point. Any advice is much appreciated. -- Posted via http://www.ruby-forum.com/.
Hello Joshua, May I inquire as to the reasoning behind needing to use DialogBlocks? Is it purely so that you can see instantly what is being created, or reusability, etc, etc, etc? I might recommend, till you get yourself comfortable with wxRuby, that you try building frames, and user interfaces by hand, through actual Ruby Code. But if you absolutely need to have a User Interface generated by DialogBlocks, and xrcise is not working for you.... Can you explain what the problem is more specifically? A lot of times, when building interfaces with XRC, you need to know what you are doing, and how xrcise is going to translate that into Ruby code for you. L8ers, On 3/7/08, Joshua Lefkowitz <lists at ruby-forum.com> wrote:> > Alex Fenton wrote: > > Joshua Lefkowitz wrote: > >> SUCCESS! > >> > >> Now, I just have to understand it all and get to my own code. > >> > >> Thanks for your help. I was just about ready to throw in the towel. > >> > > Great, glad it worked out. Feel free to ask for help; this is a friendly > > list for people with all levels of experience > > > > Good luck > > alex > > I tried to move on to apply what I learned and make my own simple > application. I started off more simple than the XRCise tutorial > example, just creating a frame through DialogBlock, then applied XRCise. > When I get to writing the ruby source code that mixes in the ruby class > file generated from XRCise, I get nowhere. I''m thinking that I''m not > just going to be able to pick this up as easily as I hoped and was > wondering if there are particular books (or chapters of books) or > websites I should be looking at to learn the basics--with respect to > GUI. I have the "pickaxe", the Ruby Way (and a couple of others), and > I''ve been all over the web, so I have a general feel for all the info > that''s out there--there''s so much out there, I''m not sure what to focus > on at this point. Any advice is much appreciated. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >-- Mario Steele http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ http://rubyforge.org/projects/vwmc/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080308/426deace/attachment.html
Mario Steele wrote:> Hello Joshua, > > May I inquire as to the reasoning behind needing to use DialogBlocks? > Is it > purely so that you can see instantly what is being created, or > reusability, > etc, etc, etc? I might recommend, till you get yourself comfortable > with > wxRuby, that you try building frames, and user interfaces by hand, > through > actual Ruby Code. But if you absolutely need to have a User Interface > generated by DialogBlocks, and xrcise is not working for you.... Can you > explain what the problem is more specifically? > > A lot of times, when building interfaces with XRC, you need to know what > you > are doing, and how xrcise is going to translate that into Ruby code for > you. > > L8ers,Mario, thanks for the input. I do need to have a GUI for my final app, but it doesn''t have to be via DialogBlocks/XRCise. I guess my question is, if I learn about GUI in say Tk, how easily will i be able to apply that to any of the other GUI aps--fxruby, wxruby, etc.? -- Posted via http://www.ruby-forum.com/.
Hello Joshua, On 3/9/08, Joshua Lefkowitz <lists at ruby-forum.com> wrote:> > > Mario, thanks for the input. I do need to have a GUI for my final app, > but it doesn''t have to be via DialogBlocks/XRCise. I guess my question > is, if I learn about GUI in say Tk, how easily will i be able to apply > that to any of the other GUI aps--fxruby, wxruby, etc.?Just a note, but when reffering to other GUI Toolkits, like Tk, FXRuby and wxRuby, they are technically GUI Libraries. As to your particular question, I strongly, very very strongly recommend staying with 1 GUI Toolkit. The reason for this, is that each GUI Toolkit library has it''s own API Interface, it''s own set of Controls, it''s own way of handling Events that come from the GUI elements. Also, there''s certain advantages and dis-advantages to using each Toolkit. Tk, is a very low level GUI Toolkit, and heavily relies on having the TK/TCL Framework installed along side Ruby in order to work. GUI Apps that are created with TK, do not truely have a native OS feel to it, and can tend to be over-complicated. FXRuby, has a Single GUI Look and Feel, so it''s garunteed to look the same across all platforms, though that is not always a good thing. The reason why it looks the same no matter what platform you run on, is cause Fox does all of it''s own drawing for all the controls that it has associated with it. I have found many times over, that with this method of drawing controls, can lend to be a main cause for bottlenecks in programs developed in Ruby. Everything is compiled in with the Extension, so you don''t need to re-distribute a whole bunch of stuff, just a single .so file and a few .rb files, which makes it a lot easier to port. wxRuby on the other hand, utilizes Native OS Controls wherever possible, only substituting for controls that do not exist on the platform in question. It''s very fast, and has very few bottlenecks, cause it''s not custom drawing every single control, outside of the main Window. This is favorable, cause it will retain the user''s preferences for Font size, control colors, layout, etc, etc. Also, as with FXRuby, wxRuby has a single SO File, and a few .rb files, making distrobution easier. Going between these three toolkits, can be very fustrating when your trying to develop apps. Do note, that these are my own opinions, and experiences from using these three Toolkits, and even though I develop soley with wxRuby, I encourage people to experiment with other libraries, but only pick 1 toolkit in which to do any programming with, otherwise, it will get harder and more frustrating in which to do stuff, any other way. If you have any other questions, please feel free to ask away! L8ers, -- Mario Steele http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ http://rubyforge.org/projects/vwmc/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080309/f6e14d28/attachment-0001.html
Mario Steele wrote:> I strongly, very very strongly recommend staying with 1 GUI Toolkit.I can''t second that enough... :-) I came to Ruby/wxRuby from Windows (VB6, .NET), Java , and then Qt3/C++ development... so I was accustomed to really only having 1 choice for the gui toolkit... Well, with Ruby I had many to choose from and it was hard to decide at first. I looked at the Qt bindings for Ruby since I was working with Qt3 at the time... I found them to be okay (well, a bit quirky and incomplete on the Mac), but I did not want to lock myself into the "GPL or pay" licensing scheme that using Qt requires. I then looked at FOX (no Mac support, somewhat visually unappealing), Tk (ugly code *grin*, no Ruby support yet for new, nice looking widgets), GTK (spurious errors, deployment headaches)... I was intially avoiding wxWindows, thinking it had pretty much run out of steam. However, I am glad to find I was wrong. It seems to me to have the best blend of features, looks nice on every platform, and it is very easy to deploy with a Ruby app via the binary gems... Oh, yeah, back to my point :-) In order to test, I wrote a little app in all of the toolkits I evaluated ... each got to various stages of completion as I hit obstacles or lost interest in subjecting myself to the pain encountered in working with them... and by the time I gave wxWidgets/wxRuby a go, my head was spinning with so many varied approaches to events, naming, threading and so on ... I ended up struggling more with wxRuby than I might have otherwise... :-) All in all, though, my evaluation experiences proved helpful. I am much more inclined now to work through any issues I may encounter with wxRuby because I know the "grass is not greener" with any other toolkit. Cheers, Tim -- Posted via http://www.ruby-forum.com/.
Tim, Mario, Thanks for your informative input. I think I''ll stick to trying to learn wxruby. I will try learning to code everything manually. I''ll follow the online tutorials and decipher the examples as best as I can. Any other suggestions are greatly appreciated. -- Posted via http://www.ruby-forum.com/.
Joshua Lefkowitz wrote:> Tim, Mario, > > Thanks for your informative input. I think I''ll stick to trying to > learn wxruby. I will try learning to code everything manually. I''ll > follow the online tutorials and decipher the examples as best as I can. > Any other suggestions are greatly appreciated.No problem... and if it helps, feel free to post code and questions here. I, too, am using DialogBlocks and xrcise with my apps and am still relatively new to wxRuby, but I''ll be more than happy to help out any way I can... Cheers, Tim -- Posted via http://www.ruby-forum.com/.
Hey Joshua, On 3/9/08, Joshua Lefkowitz <lists at ruby-forum.com> wrote:> Tim, Mario, > > Thanks for your informative input. I think I''ll stick to trying to > learn wxruby. I will try learning to code everything manually. I''ll > follow the online tutorials and decipher the examples as best as I can. > Any other suggestions are greatly appreciated.Your quite welcome for the input. If you have any questions about how Widgets work, and so on, feel free to ask, as one of us devs, or another user on the Mailing List, will be more then happy to help you out with it. Examples is the best way to learn how things work within wxRuby, as it is pretty much as it''s shown there. It does take some time to learn, but don''t get discouraged so easily. As Tim has pointed out, other toolkits are hard to work with, and some are not even fully cross-platform, or are a headache to deploy in any case. Another nice thing that you will have with wxRuby, compared with other Toolkits, is the users, we have a Chat room #wxruby on irc.freenode.net, we have the Mailing List, and we consider ourselvs a very helpful bunch, even to those who are new not to just wxRuby, but new to Ruby itself to. Not very many other Toolkits can say the same. Good luck with your learning experince, and again, ask any questions you may have, and feel free to look through our Mailing List Archives, there''s quite a bit of information that has been discussed in the past over the mailing list, that can be easily looked through. L8ers, -- Mario Steele http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ http://rubyforge.org/projects/vwmc/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080309/a7d14599/attachment.html