-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I open the same window twice #45
Comments
require 'fox16'
include Fox
class HelloWorld < FXMainWindow
def initialize(app, t)
super(app, "Hello, #{t}" , :width => 200, :height => 50)
end
def create
super
show(PLACEMENT_SCREEN)
end
end
def show_window(t)
app = FXApp.instance || FXApp.new
app.create
w = HelloWorld.new(app, t)
w.create
app.run
end
show_window(1)
show_window(2)
show_window(3) It is not allowed to create more than one FXApp instances at the same time. Nevertheless I think there should be a way to destroy a FXApp instance and create a new one. I'll check if I can add such a method. |
Lars,
I think a FXApp release or destroy is needed.
I will use your solution in mean while, please keep maintaining this framework, since it is very well designed and in my humble opinion the best GUI framework for Ruby.
Thank you so much for your prompt reply.
Get Outlook for Android<https://aka.ms/ghei36>
…________________________________
From: Lars Kanis <[email protected]>
Sent: Friday, March 23, 2018 7:41:21 AM
To: larskanis/fxruby
Cc: murathp; Author
Subject: Re: [larskanis/fxruby] How can I open the same window twice (#45)
create is a bit tricky in FXRuby: It is called while the initial FXApp.create call, but subsequently allocated Widgets needs to be created explicitly. In addition to this there's currently no way to destroy a FXApp once created. So you have to reuse it like so:
require 'fox16'
include Fox
class HelloWorld < FXMainWindow
def initialize(app, t)
super(app, "Hello, #{t}" , :width => 200, :height => 50)
end
def create
super
show(PLACEMENT_SCREEN)
end
end
def show_window(t)
app = FXApp.instance || FXApp.new
app.create
w=HelloWorld.new(app, t)
w.create
app.run
end
show_window(1)
show_window(2)
show_window(3)
It is not allowed to create more than one FXApp instances at the same time. Nevertheless I think there should be a way to destroy a FXApp instance and create a new one. I'll check if I can add such a method.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#45 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AME_WyrnKuYIAJvM9QUmiscaeSHDiv0Mks5thN9ggaJpZM4S4Gel>.
|
Hi,
I am trying to use fxruby to open a FileDialog multiple times through out the execution of the main ruby program which is not a GUI program. The main program executes, then there is a need to open a directory to pick a file and submit. And then pick another file and submit, so it is in a loop.
I see the following error: attempted to create more than one FXApp instance (RuntimeError)
To simplify my question, I am copying the following code.
If a user wanted to reopen the Hello World box twice in the same program once the first box is closed by clicking on the red (x) of the windows (upper right corner), how would he restart it again in the same program. I tried .exit, .destroy with subsequent object recreations and that did not work.
require 'fox16'
include Fox
class HelloWorld < FXMainWindow
def initialize(app)
super(app, "Hello, World!" , :width => 200, :height => 50)
end
def create
super
show(PLACEMENT_SCREEN)
end
end
app = FXApp.new
HelloWorld.new(app)
app.create
app.run
app.exit
HelloWorld.new(app)
app.create
app.run
The text was updated successfully, but these errors were encountered: