Pygtk-calendar-class
提供:Dev Guides
PyGTK-カレンダークラス
PyGTKツールキットのカレンダーウィジェットは、一度に1か月表示のシンプルなカレンダーを表示します。 月と年を変更するためのナビゲーションコントロールがデフォルトで表示されます。 表示オプションは適切に構成できます。
monthプロパティの値は0〜11、dateプロパティの値は1〜31です。
gtk.Calendarオブジェクトを作成する簡単なコンストラクタがあります-
デフォルトの表示スタイルでは、現在の月と年、および曜日の名前が表示されます。
gtk.Calendarクラスには次のメソッドがあります-
- Calendar.select_month(mm、yy)—これにより、カレンダー表示が指定された mm および yy に変更されます。
- Calendar.select_day(dd)—これは、カレンダーの値が1から31の間である場合、カレンダーで指定された dd を選択します dd が0の場合、現在の日の選択は削除されます。
- Calendar.display_options()—これは、カレンダー表示オプションを flags で指定された値に設定します。 可能な表示オプションは次の組み合わせです。
gtk.CALENDAR_SHOW_HEADING | Specifies that the month and year should be displayed. |
gtk.CALENDAR_SHOW_DAY_NAMES | Specifies that three letter day descriptions should be present. |
gtk.CALENDAR_NO_MONTH_CHANGE | Prevents the user from switching months with the calendar. |
gtk.CALENDAR_SHOW_WEEK_NUMBERS | Displays each week numbers of the current year, down the left side of the calendar. |
gtk.CALENDAR_WEEK_START_MONDAY | Starts the calendar week on Monday, instead of the default Sunday. |
- Calendar.get_date()—カレンダーの現在の年、月、および選択された日番号をタプル(年、月、日)として取得します。
gtk.Calendarウィジェットは、次の信号を発します-
day-selected | This is emitted when a day is selected either by the user or programmatically. |
month-changed | This is emitted when the calendar month is changed programmatically or by the user. |
next-month | This is emitted when the user clicks the "next-month" navigation control in the calendar header. |
next-year | This is emitted when the user clicks the "next-year" navigation control in the calendar header. |
prev-month | This is emitted when the user clicks the "prev-month" navigation control in the calendar header. |
prev-year | This is emitted when the user clicks the "prev-year" navigation control in the calendar header. |
次の例では、gtk.Calendarコントロールと4つのボタンがトップレベルウィンドウに配置されています。
「見出し」ボタンをクリックすると、カレンダーの表示オプションがSHOW_HEADINGに設定されます-
ユーザーが「曜日名」ボタンをクリックすると、コールバックは表示オプションをSHOW_DAY_NAMESに設定します-
「両方」ボタンを押すと、両方の表示オプションが有効になります。 まず、表示オプションのすべてのフラグを0に設定して削除します。
「設定」ボタンは、現在マークされている日付を表示するメッセージボックスをポップアップします。
例
次のコードを観察してください-
上記のコードは、次の出力を生成します-