Hello. I have a problems. Can you help me? I create GUI-program, based on wxWidgets, in wxFormBuilder. 1.jpg) I create a form in wxFormBuilder, it will see as left part of image. If i test it on View->XRC WIndow, it see as the right part of 1.jpg. What is it? 2.jpg) I generated code and start compilize it. But it failed. Why? Thanks in advance -- Posted via http://www.ruby-forum.com/.
Else one problem.
3) I create an application by Ctrl-C from one of lessons:
--------
require ''wx''
include Wx
class MyFrame < Frame
def initialize()
super(nil, -1, ''My Frame Title'')
# First create the controls
@my_panel = Panel.new(self)
@my_label = StaticText.new(@my_panel, -1, ''My Label
Text'',
DEFAULT_POSITION, DEFAULT_SIZE, ALIGN_CENTER)
@my_textbox = TextCtrl.new(@my_panel, -1, ''Default Textbox
Value'')
@my_combo = ComboBox.new(@my_panel, -1, ''Default Combo
Text'',
DEFAULT_POSITION, DEFAULT_SIZE, [''Item 1'', ''Item
2'', ''Item 3''])
@my_button = Button.new(@my_panel, -1, ''My Button
Text'')
# Bind controls to functions
evt_button(@my_button.get_id()) { |event|
my_button_click(event)}
# Now do the layout
@my_panel_sizer = BoxSizer.new(VERTICAL)
@my_panel.set_sizer(@my_panel_sizer)
@my_panel_sizer.add(@my_label, 0, GROW|ALL, 2)
@my_panel_sizer.add(@my_textbox, 0, GROW|ALL, 2)
@my_panel_sizer.add(@my_combo, 0, GROW|ALL, 2)
@my_panel_sizer.add(@my_button, 0, GROW|ALL, 2)
show()
end
def my_button_click(event)
# Your code here
end
end
class MyApp < App
def on_init
MyFrame.new
end
end
MyApp.new.main_loop()
-------
I run it, but it window doesn''t open. In command prompt all work fint,
but doesn''t open. What''s matter?
--
Posted via http://www.ruby-forum.com/.
Hello Misha, First off, welcome to wxRuby community. I''ll answer your other question in a few, first we''ll cover this one. On Wed, Oct 13, 2010 at 2:49 AM, Misha Ognev <lists at ruby-forum.com> wrote:> Else one problem. > > 3) I create an application by Ctrl-C from one of lessons: > > -------- > > require ''wx'' > include Wx > > class MyFrame < Frame > def initialize() > super(nil, -1, ''My Frame Title'') > # First create the controls > @my_panel = Panel.new(self) > @my_label = StaticText.new(@my_panel, -1, ''My Label Text'', > DEFAULT_POSITION, DEFAULT_SIZE, ALIGN_CENTER) > @my_textbox = TextCtrl.new(@my_panel, -1, ''Default Textbox > Value'') > @my_combo = ComboBox.new(@my_panel, -1, ''Default Combo Text'', > DEFAULT_POSITION, DEFAULT_SIZE, [''Item 1'', ''Item 2'', ''Item 3'']) > @my_button = Button.new(@my_panel, -1, ''My Button Text'') > # Bind controls to functions > evt_button(@my_button.get_id()) { |event| > my_button_click(event)} > # Now do the layout > @my_panel_sizer = BoxSizer.new(VERTICAL) > @my_panel.set_sizer(@my_panel_sizer) > @my_panel_sizer.add(@my_label, 0, GROW|ALL, 2) > @my_panel_sizer.add(@my_textbox, 0, GROW|ALL, 2) > @my_panel_sizer.add(@my_combo, 0, GROW|ALL, 2) > @my_panel_sizer.add(@my_button, 0, GROW|ALL, 2) > show() > end > > def my_button_click(event) > # Your code here > end > > end > > class MyApp < App > def on_init > MyFrame.newend> end > > MyApp.new.main_loop() > > ------- > > I run it, but it window doesn''t open. In command prompt all work fint, > but doesn''t open. What''s matter? > >First off, this is correct in the code, till you get to your on_init method. I can tell you, that your Window is being created, and everything, but your not showing it to the user. There''s two ways in which you can do this. The first, is to simply do: MyFrame.new.show() Which will show your frame to the user, after it is created. The second, is to store the instance of your Window in a variable, and call show in it, like this: myframe = MyFrame.new myframe.show In both cases, you need to call the show method on your Frame, in order to have your frame actually be displayed. It isn''t done automatically, cause there may be times, where you want to create a window, but not show it, in such cases as having a Tray Icon on Windows / Linux, and a Dock Icon on OS X (EG The Bottom bar.) hth with this one, Mario -- Mario Steele -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20101013/3b2baa56/attachment-0001.html>
Hello Again Misha, On Tue, Oct 12, 2010 at 3:31 PM, Misha Ognev <lists at ruby-forum.com> wrote:> Hello. I have a problems. Can you help me? > > I create GUI-program, based on wxWidgets, in wxFormBuilder. > > 1.jpg) I create a form in wxFormBuilder, it will see as left part of > image. If i test it on View->XRC WIndow, it see as the right part of > 1.jpg. What is it? >1.jpg) This is the cause of the fact that in your XRC Design, you do not have a root Layout manager, meaning that the window needs to have a VerticalSizer or a HorizontalSizer as the root item, in order to manage layouts of all the controls in your window, otherwise, you have to do the management of the layout yourself, meaning you need to keep tabs on the window sizes, and control positions, and re-positioning your controls yourself. This also means that wxWidgets will not manage the window size, and therefore, will allocate the minimal size for your window, which gives you the issues you are seeing in 1.jpg.> > 2.jpg) I generated code and start compilize it. But it failed. Why? >This is an issue with Ruby 1.9.1, they made String where it is no longer Enumerable, meaning that there is no .each method, that will parse through each actual line of text in the code, as is done in Ruby 1.8. I will see about getting a new gem built, with a patch to fix that soon.> Thanks in advance > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >hth, -- Mario Steele -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20101013/3c1a5939/attachment.html>
Thanks. Now I''m a new wx''er.
BTW, Misha on russian equivalent Michael in english :)
How you do the letters green?
1) I create forms now in DialogBlocks 4.39 (next - DB). If I do not
create a menubar, it''s OK. If I add it, I need to change a PLATFORM
value on it from any to some. It''s normal?
2) Conversion is normal in DB - in my opinion, the question is closed.
3) I copy code, but it not works:
------
require ''wx''
include Wx
class MyFrame < Frame
def initialize()
super(nil, -1, ''My Frame Title'')
# First create the controls
@my_panel = Panel.new(self)
@my_label = StaticText.new(@my_panel, -1, ''My Label
Text'',
DEFAULT_POSITION, DEFAULT_SIZE, ALIGN_CENTER)
@my_textbox = TextCtrl.new(@my_panel, -1, ''Default Textbox
Value'')
@my_combo = ComboBox.new(@my_panel, -1, ''Default Combo
Text'',
DEFAULT_POSITION, DEFAULT_SIZE, [''Item 1'', ''Item
2'', ''Item 3''])
@my_button = Button.new(@my_panel, -1, ''My Button
Text'')
# Bind controls to functions
evt_button(@my_button.get_id()) { |event|
my_button_click(event)}
# Now do the layout
@my_panel_sizer = BoxSizer.new(VERTICAL)
@my_panel.set_sizer(@my_panel_sizer)
@my_panel_sizer.add(@my_label, 0, GROW|ALL, 2)
@my_panel_sizer.add(@my_textbox, 0, GROW|ALL, 2)
@my_panel_sizer.add(@my_combo, 0, GROW|ALL, 2)
@my_panel_sizer.add(@my_button, 0, GROW|ALL, 2)
show()
end
def my_button_click(event)
# Your code here
end
end
class MyApp < App
def on_init
MyFrame.new
end
end
MyApp.new.main_loop()
myframe = MyFrame.new.show()
---------
There isn''t a .xrc file in this folder. It''s only .rb file. It
doesn''t
work...
Can you give me some working simple window code to Copy-Paste in .rb
file as example of ruby-GUI-application.
Sorry for my english, Misha.
--
Posted via http://www.ruby-forum.com/.
Why everyone is silent? -- Posted via http://www.ruby-forum.com/.
> > Can you give me some working simple window code to Copy-Paste in .rb > file as example of ruby-GUI-application. > >Into the installation of wxruby gem, you can find many examples to try on. bio. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20101017/573131bf/attachment.html>
This code:
#!/usr/bin/env ruby
require ''rubygems''
require ''wx''
class MyApp < Wx::App
def on_init
@frame = Wx::Frame.new( nil, -1, "Application" )
@frame.show
end
end
app = MyApp.new
app.main_loop
app.show
Doesn''t work. It show only command prompt with ruby, which close after
working code. I didn''t see GUI window. Why?
Maybe I don''t install something? What I must install to wxruby gui
start
to work?
--
Posted via http://www.ruby-forum.com/.
On 17/10/2010 18:16, Misha Ognev wrote:> This code:...> Doesn''t work. It show only command prompt with ruby, which close after > working code. I didn''t see GUI window. Why?Run it in a command prompt and *post the error message*, then we can help. There is a sample called ''minimal.rb'' in the distribution that you can use as a basis for testing and the starting point for your own apps. a
Piture is error message. This is testing of my application. Attachments: http://www.ruby-forum.com/attachment/5212/3.jpg -- Posted via http://www.ruby-forum.com/.