-
-
Save dsisnero/f2eccc81985907ea21741e6477584fdd to your computer and use it in GitHub Desktop.
エラーダイヤログ表示
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
require 'tk' | |
require 'pp' | |
class TkWindow_Main | |
def initialize() | |
@root = TkRoot.new { | |
title 'Root' | |
resizable [0,0] | |
} | |
TkButton.new(@root, | |
'text' => "Check", | |
'command' => proc { | |
check_file | |
} | |
).pack | |
end | |
def check_file() | |
if !File.exist?("hogehoge.txt") | |
TkWindow_Sub.new(1) | |
end | |
end | |
end | |
class TkWindow_Sub | |
def initialize(error_code) | |
sub_window = TkToplevel.new() { | |
title 'Sub Window' | |
resizable [0,0] | |
grab | |
} | |
@wdg_txt = TkText.new(sub_window) { | |
height '5' | |
width '30' | |
}.pack('padx' => 5, 'pady' => 5) | |
@wdg_txt.insert('end', getMsg(error_code)) | |
@wdg_txt.state('disabled') | |
TkButton.new(sub_window, | |
'text' => "OK", | |
'command' => proc { | |
sub_window.destroy | |
} | |
).pack('side' => 'right', 'padx' => 5) | |
end | |
def getMsg(error_code) | |
if error_code==1 | |
return "file not exist" | |
end | |
end | |
end | |
if $0 == __FILE__ | |
TkWindow_Main.new() | |
Tk.mainloop | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment