/usr/share/help/ko/gnome-devel-demos/messagedialog.py.page is in gnome-devel-docs 3.28.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | <?xml version="1.0" encoding="utf-8"?>
<page xmlns="http://projectmallard.org/1.0/" xmlns:its="http://www.w3.org/2005/11/its" xmlns:xi="http://www.w3.org/2001/XInclude" type="guide" style="task" id="messagedialog.py" xml:lang="ko">
<info>
<title type="text">MessageDialog(Python)</title>
<link type="guide" xref="beginner.py#windows"/>
<link type="next" xref="gmenu.py"/>
<revision version="0.1" date="2012-06-11" status="draft"/>
<credit type="author copyright">
<name>Marta Maria Casetti</name>
<email its:translate="no">mmcasetti@gmail.com</email>
<years>2012</years>
</credit>
<desc>메시지 창</desc>
<mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
<mal:name>조성호</mal:name>
<mal:email>shcho@gnome.org</mal:email>
<mal:years>2017</mal:years>
</mal:credit>
</info>
<title>MessageDialog</title>
<media type="image" mime="image/png" src="media/messagedialog.png"/>
<p>선택에 따라 메시지를 터미널에 출력하는 메시지 대화 상자입니다.</p>
<links type="section"/>
<section id="code">
<title>예제 결과를 만드는 코드</title>
<code mime="text/x-python" style="numbered">from gi.repository import Gtk
from gi.repository import Gio
import sys
class MyWindow(Gtk.ApplicationWindow):
# constructor for a window (the parent window) with a label
def __init__(self, app):
Gtk.Window.__init__(self, title="GMenu Example", application=app)
self.set_default_size(400, 200)
label = Gtk.Label()
label.set_text("This application goes boom!")
self.add(label)
# create the message_action (a Gio.SimpleAction) - for the window
message_action = Gio.SimpleAction.new("message", None)
# connect the signal from the action to the function message_cb()
message_action.connect("activate", self.message_cb)
# add the action to the application
app.add_action(message_action)
# callback function for the signal "activate" from the message_action
# in the menu of the parent window
def message_cb(self, action, parameter):
# a Gtk.MessageDialog
messagedialog = Gtk.MessageDialog(parent=self,
flags=Gtk.DialogFlags.MODAL,
type=Gtk.MessageType.WARNING,
buttons=Gtk.ButtonsType.OK_CANCEL,
message_format="This action will cause the universe to stop existing.")
# connect the response (of the button clicked) to the function
# dialog_response()
messagedialog.connect("response", self.dialog_response)
# show the messagedialog
messagedialog.show()
def dialog_response(self, widget, response_id):
# if the button clicked gives response OK (-5)
if response_id == Gtk.ResponseType.OK:
print("*boom*")
# if the button clicked gives response CANCEL (-6)
elif response_id == Gtk.ResponseType.CANCEL:
print("good choice")
# if the messagedialog is destroyed (by pressing ESC)
elif response_id == Gtk.ResponseType.DELETE_EVENT:
print("dialog closed or cancelled")
# finally, destroy the messagedialog
widget.destroy()
class MyApplication(Gtk.Application):
def __init__(self):
Gtk.Application.__init__(self)
def do_activate(self):
win = MyWindow(self)
win.show_all()
def quit_cb(self, action, parameter):
self.quit()
def do_startup(self):
Gtk.Application.do_startup(self)
# create a menu (a Gio.Menu)
menu = Gio.Menu()
# append a menu item with label "Message" and action "app.message"
menu.append("Message", "app.message")
# append a menu item with label "Quit" and action "app.quit"
menu.append("Quit", "app.quit")
# set menu as the menu for the application
self.set_app_menu(menu)
# a new simpleaction - for the application
quit_action = Gio.SimpleAction.new("quit", None)
quit_action.connect("activate", self.quit_cb)
self.add_action(quit_action)
app = MyApplication()
exit_status = app.run(sys.argv)
sys.exit(exit_status)
</code>
</section>
<section id="methods">
<title>MessageDialog 위젯에 쓸만한 메서드</title>
<p>18번째 줄에서 <code>"activate"</code> 시그널은 <code><var>widget</var>.connect(<var>signal</var>, <var>callback function</var>)</code> 함수로 <code>message_cb()</code> 콜백 함수에 연결했습니다. 더 자세한 설명은 <link xref="signals-callbacks.py"/>를 참조하십시오.</p>
<list>
<item><p>MessageDialog 생성자에서 <code>Gtk.DialogFlags.DESTROY_WITH_PARENT</code> 플래그(상위 창을 해체할 때 messagedialog 창을 해체) 또는 <code>Gtk.DialogFlags.MODAL</code> 플래그(프로그램의 다른 창과 동작하지 않음)을 설정할 수 있습니다.</p></item>
<item><p>MessageDialog 생성자에서 원하는 메시지 형식에 따라 <code>Gtk.MessageType.INFO, Gtk.MessageType.WARNING, Gtk.MessageType.QUESTION, Gtk.MessageType.ERROR, Gtk.MessageType.OTHER</code> 중 하나를 설정할 수 있습니다.</p></item>
<item><p>MessageDialog 생성자에서 <code>Gtk.ButtonsType.NONE, Gtk.ButtonsType.OK, Gtk.ButtonsType.CLOSE, Gtk.ButtonsType.CANCEL, Gtk.ButtonsType.YES_NO, Gtk.ButtonsType.OK_CANCEL</code> 또는 Gtk.Dialog에서와 같이 <code>add_button()</code>를 활용한 그 어떤 요소든 단추로 설정할 수 있습니다.</p></item>
<item><p>다른 그림을 활용하여 MessageDialog의 기본 그림을 대신할 수 있습니다.</p>
<code mime="text/x-python">
image = Gtk.Image()
image.set_from_stock(Gtk.STOCK_CAPS_LOCK_WARNING, Gtk.IconSize.DIALOG)
image.show()
messagedialog.set_image(image)</code>
<p><code>Gtk.STOCK_CAPS_LOCK_WARNING</code>은 <link href="http://developer.gnome.org/gtk3/unstable/gtk3-Stock-Items.html">스톡 항목</link>의 그림입니다. <code>image.set_from_file("filename.png")</code> 코드로 그림 위젯처럼 어떤 그림이든 설정할 수 있습니다.</p></item>
<item><p><code>format_secondary_text("some secondary message")</code>는 부차적인 메시지를 설정합니다. 주 텍스트는 굵은 글씨로 나타납니다.</p></item>
</list>
</section>
<section id="references">
<title>API 참고서</title>
<p>이 예제는 다음 참고자료가 필요합니다:</p>
<list>
<item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkMessageDialog.html">GtkMessageDialog</link></p></item>
<item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkDialog.html">GtkDialog</link></p></item>
<item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkWindow.html">GtkWindow</link></p></item>
<item><p><link href="http://developer.gnome.org/gio/stable/GSimpleAction.html">GSimpleAction</link></p></item>
<item><p><link href="http://developer.gnome.org/gio/unstable/GActionMap.html">GActionMap</link></p></item>
<item><p><link href="http://developer.gnome.org/gio/stable/GMenu.html">GMenu</link></p></item>
<item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkApplication.html">GtkApplication</link></p></item>
</list>
</section>
</page>
|