PyGobject(六十六)Gtk.Widget之Gtk.Calendar

本文介绍Gtk.Calendar组件的使用方法,包括其属性、信号和方法。通过一个Python示例展示了如何创建日历,设置细节显示,并连接各种事件处理函数。

Gtk.Calendar

日历部件

继承关系

这里写图片描述

Methods

方法修饰词方法名及参数
staticnew ()
clear_marks ()
get_date ()
get_day_is_marked (day)
get_detail_height_rows ()
get_detail_width_chars ()
get_display_options ()
mark_day (day)
select_day (day)
select_month (month, year)
set_detail_func (func, *data)
set_detail_height_rows (rows)
set_detail_width_chars (chars)
set_display_options (flags)
unmark_day (day)

Virtual Methods

do_day_selected ()
do_day_selected_double_click ()
do_month_changed ()
do_next_month ()
do_next_year ()
do_prev_month ()
do_prev_year ()

Properties

NameTypeFlagsShort Description
dayintr/w/enThe selected day (as a number between 1 and 31, or 0 to unselect the currently selected day)
detail-height-rowsintr/w/enDetails height in rows
detail-width-charsintr/w/enDetails width in characters
monthintr/w/enThe selected month (as a number between 0 and 11)
no-month-changeboolr/w/enIf True, the selected month cannot be changed
show-day-namesboolr/w/enIf True, day names are displayed
show-detailsboolr/w/enIf True, details are shown
show-headingboolr/w/enIf True, a heading is displayed
show-week-numbersboolr/w/enIf True, week numbers are displayed
yearintr/w/enThe selected year

Signals

NameShort Description
day-selectedEmitted when the user selects a day.
day-selected-double-clickEmitted when the user double-clicks a day.
month-changedEmitted when the user clicks a button to change the selected month on a calendar.
next-monthEmitted when the user switched to the next month.
next-yearEmitted when user switched to the next year.
prev-monthEmitted when the user switched to the previous month.
prev-yearEmitted when user switched to the previous year.

例子

这里写图片描述
代码:

#!/usr/bin/env python3
# Created by xiaosanyu at 16/6/28
# section 107
TITLE = "Calendar"
DESCRIPTION = """
Gtk.Calendar is a widget that displays a Gregorian calendar, one month at a time
"""
import gi

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk


class CalendarWindow(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self, title="Calendar Demo")
        self.set_border_width(10)
        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        cal = Gtk.Calendar()
        self.today = cal.get_date()
        print(self.today)
        # 每个月的这一天都有标记,不合理啊
        # cal.mark_day(1)

        # show details
        cal.props.show_details = True
        # create detail
        cal.set_detail_func(self.detail, "haha")
        cal.connect("day-selected", self.day_selected)
        cal.connect("day-selected-double-click", self.day_selected_double_click)
        cal.connect("month-changed", self.month_changed)
        cal.connect("next-month", self.next_month)

        # other signals
        # next-year
        # prev-month
        # prev-year

        box.add(cal)
        self.label = Gtk.Label()
        box.add(self.label)
        self.add(box)

    def day_selected(self, cal):
        print("day_selected", cal.props.day)
        self.label.set_label("day_selected:%d" % cal.props.day)

    def day_selected_double_click(self, cal):
        print("day_selected_double_click", cal.props.day)
        self.label.set_label("day_selected_double_click:%d" % cal.props.day)

    def month_changed(self, cal):
        print("month_changed", cal.props.month + 1)
        self.label.set_label("month_changed:%d" % (cal.props.month + 1))

    def next_month(self, cal):
        print("next_month", cal.props.month + 1)
        self.label.set_label("next_month:%d" % (cal.props.month + 1))

    def detail(self, cal, y, m, d, value):
        # print(y, m, d)
        if y == self.today[0] and m == self.today[1] and d == self.today[2]:
            # 设置详细信息高度和宽度
            cal.set_detail_height_rows(2)
            cal.set_detail_width_chars(5)
            return "<b>today</b>"


def main():
    win = CalendarWindow()
    win.connect("delete-event", Gtk.main_quit)
    win.show_all()
    Gtk.main()


if __name__ == "__main__":
    main()




代码下载地址:http://download.youkuaiyun.com/detail/a87b01c14/9594728

内容概要:本文围绕六自由度机械臂的人工神经网络(ANN)设计展开,重点研究了正向与逆向运动学求解、正向动力学控制以及基于拉格朗日-欧拉法推导逆向动力学方程,并通过Matlab代码实现相关算法。文章结合理论推导与仿真实践,利用人工神经网络对复杂的非线性关系进行建模与逼近,提升机械臂运动控制的精度与效率。同时涵盖了路径规划中的RRT算法与B样条优化方法,形成从运动学到动力学再到轨迹优化的完整技术链条。; 适合人群:具备一定机器人学、自动控制理论基础,熟悉Matlab编程,从事智能控制、机器人控制、运动学六自由度机械臂ANN人工神经网络设计:正向逆向运动学求解、正向动力学控制、拉格朗日-欧拉法推导逆向动力学方程(Matlab代码实现)建模等相关方向的研究生、科研人员及工程技术人员。; 使用场景及目标:①掌握机械臂正/逆运动学的数学建模与ANN求解方法;②理解拉格朗日-欧拉法在动力学建模中的应用;③实现基于神经网络的动力学补偿与高精度轨迹跟踪控制;④结合RRT与B样条完成平滑路径规划与优化。; 阅读建议:建议读者结合Matlab代码动手实践,先从运动学建模入手,逐步深入动力学分析与神经网络训练,注重理论推导与仿真实验的结合,以充分理解机械臂控制系统的设计流程与优化策略。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sanxiaochengyu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值