为何无法全屏?

软件和网站开发以及相关技术探讨
回复
罗非鱼
帖子: 980
注册时间: 2008-04-12 12:44

为何无法全屏?

#1

帖子 罗非鱼 » 2010-08-08 21:03

require 'gtk2'
class RubyApp < Gtk::Window
def initialize
super
set_title "Center"
signal_connect "destroy" do
Gtk.main_quit
end
decorated=false
move 0, 0
gdk_screen=screen
resize gdk_screen.width, gdk_screen.height
show
end
end
window = RubyApp.new
Gtk.main
上面的ruby代码运行后,可以全屏,下面的就不行,不知错误在哪里?
require 'gtk2'
def callback(widget)
puts "Hello again - #{widget.label}(#{widget}) was pressed."
end
window = Gtk::Window.new
window.title = "Hello Buttons"
window.border_width = 10
window.signal_connect('delete_event') do
Gtk.main_quit
false
end
box1 = Gtk::HBox.new(false, 0)
window.add(box1)
button1 = Gtk::Button.new("Button 1")
button1.signal_connect( "clicked" ) do |w|
callback(w)
end
box1.pack_start(button1, true, true, 0)
button2 = Gtk::Button.new("Button 2")
button2.signal_connect("clicked") do |w|
callback(w)
end
box1.pack_start(button2, true, true, 0)
window.decorated=false
window.move 0, 0
window.gdk_screen=screen
window.resize gdk_screen.width, gdk_screen.height
window.show_all
Gtk.main

the output is:

irb(main):026:0> window.gdk_screen=screen
NameError: undefined local variable or method `screen' for main:Object
from (irb):26
from :0
irb(main):027:0> window.resize gdk_screen.width, gdk_screen.height
NameError: undefined local variable or method `gdk_screen' for
main:Object
from (irb):27
from :0
头像
slax
帖子: 1099
注册时间: 2009-08-17 3:52

Re: 为何无法全屏?

#2

帖子 slax » 2010-08-09 9:27

不知道,gtk里一句

代码: 全选

gtk_window_maximize
就OK了
We believe that the internet should be public, open and accessible.
软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。
iceplayer! linux音乐新体验~ 最新版本4.0.5-20110520已更新!viewtopic.php?f=137&t=252461
想要iceplayer 测试版麼?加入QQ群80071264吧,在code.google也可找到
http://www.iceplayer.org/
http://jasy.ice.blog.163.com/
回复