当前位置: 首页>>代码示例>>Python>>正文


Python DataBase.select方法代码示例

本文整理汇总了Python中database.DataBase.select方法的典型用法代码示例。如果您正苦于以下问题:Python DataBase.select方法的具体用法?Python DataBase.select怎么用?Python DataBase.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在database.DataBase的用法示例。


在下文中一共展示了DataBase.select方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: page_set_thread

# 需要导入模块: from database import DataBase [as 别名]
# 或者: from database.DataBase import select [as 别名]
def page_set_thread(page_dict, index, favourite, database_search):    ## function modified
    'each such 26 threads will create the 26 pages of the notebook'

    h_box = gtk.HBox(False, 20)
    v_box = gtk.VBox()
    h_box.pack_start(v_box)
    table = chr(ord('a') + index)
    database = DataBase()
    count = 0
    if database.row_count(table):
        words = database.select(table)
        count += 1
        link = gtk.LinkButton('')
        link.set_label(words[0][0])
        link.connect('clicked', linked, favourite, database_search)
        link.set_tooltip_text('click to search')
        alignment = gtk.Alignment(0, 0.5, 0, 0)
        alignment.add(link)
        v_box.pack_start(alignment)
    for number in range(26):
        if database.row_count(table + chr(ord('a') + number)):
            words = database.select(table + chr(ord('a') + number))
            for word in words:
                count += 1
                link = gtk.LinkButton('')
                link.set_label(word[0])
                link.connect('clicked', linked, favourite, database_search)
                link.set_tooltip_text('click to search')
                alignment = gtk.Alignment(0, 0.5, 0, 0)
                alignment.add(link)
                v_box.pack_start(alignment)
                if count >= 25:
                    count -= 25
                    alignment = gtk.Alignment(0, 0, 0, 0)
                    v_box = gtk.VBox()
                    alignment.add(v_box)
                    h_box.pack_start(alignment)
    database.close()
    alignment = gtk.Alignment(0, 0, 0, 0)
    alignment.add(h_box)
    scroll = gtk.ScrolledWindow()
    scroll.set_size_request(400, 400)
    scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
    scroll.add_with_viewport(alignment)
    scroll.get_child().modify_bg(gtk.STATE_NORMAL,
                                 gtk.gdk.color_parse('#ffffff'))
    page_dict[chr(ord('A') + index)] = scroll
    return
开发者ID:dibyendu,项目名称:Plexicon,代码行数:50,代码来源:interface.py

示例2: __save

# 需要导入模块: from database import DataBase [as 别名]
# 或者: from database.DataBase import select [as 别名]
    def __save(self, unused):
        'saves the contact details'

        def show_message(msg_type, msg_format, text, button =
                         gtk.BUTTONS_CLOSE):
            '''
            shows warning/error messages if
            anything goes wrong in contact info
            '''

            def set_flag(unused_button):
                '''
                sets the flag to overwrite same
                contact name with newer details
                '''

                self.__over_write = True
                return False
            self.__over_write = False
            message = gtk.MessageDialog(type = msg_type, message_format =
                                        msg_format, buttons = button)
            message.format_secondary_markup(text)
            message.set_icon_from_file(ICON_PATH + '/contact.png')
            if button == gtk.BUTTONS_YES_NO:
                message.get_child().get_children()[-1].get_children()[0].\
                                            connect('clicked', set_flag)
            message.run()
            message.destroy()
        if not self.entry_list[0].get_text():
            show_message(gtk.MESSAGE_ERROR, 'ERROR', '<span font_desc=\
"belgrano 12">Name can not be empty</span>')
            return False
        elif not self.entry_list[1].get_text():
            show_message(gtk.MESSAGE_ERROR, 'ERROR', '<span font_desc="primitiv\
e 12"><span foreground="#3EA9DC"><b>' + self.entry_list[0].get_text() + \
'</b></span> must have a default number</span>')
            return False
        else:
            faulty = []
            for entry in range(1, len(self.entry_list)):
                if len(self.entry_list[entry].get_text()) < 10:
                    faulty.append(entry)
            if faulty:
                text = '<span font_desc="belgrano 12">The following contact(s)\
 has(have) less than 10 digits :\n'
                for index in faulty:
                    if index == 1:
                        text += '<b>default</b>\n'
                    else:
                        text += '#<b>' + str(index) + '</b>\n'
                text += '</span>'
                show_message(gtk.MESSAGE_ERROR, 'ERROR', text)
                return False
        values = [self.entry_list[1].get_text(), self.entry_list[0].get_text()]
        for entry in self.entry_list[2:]:
            values.append(entry.get_text())
        values = tuple(values)
        from database import DataBase
        database = DataBase()
        if database.row_count('contacts', self.entry_list[1].get_text()):
            show_message(gtk.MESSAGE_WARNING, 'WARNING', '<span font_desc="belgrano 12">Number <span foreground="#0000FF"><b>' + \
self.entry_list[1].get_text() + '</b></span> is already in use for <span foreground="#FF0000"><b>%s</b></span>\n\nOverwrite the \
details for <span foreground="#077E11"><b>%s</b></span> ?</span>' % (database.select('contacts', self.entry_list[1].get_text())[0][0],
self.entry_list[0].get_text()), gtk.BUTTONS_YES_NO)
            if self.__over_write:
                database.update('contacts', values)
                database.close()
                self.destroy()
        else:
            database.update('contacts', values)
            database.close()
            self.destroy()
开发者ID:dibyendu,项目名称:WayToSms,代码行数:74,代码来源:contacts.py


注:本文中的database.DataBase.select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。