コード例 #1
0
 def showqrcode(w, treeview, liststore):
     path, col = treeview.get_cursor()
     if not path: return
     address = liststore.get_value(liststore.get_iter(path), 0)
     qr = pyqrnative.QRCode(4, pyqrnative.QRErrorCorrectLevel.H)
     qr.addData(address)
     qr.make()
     boxsize = 7
     boxcount_row = qr.getModuleCount()
     size = (boxcount_row + 4) * boxsize
     def area_expose_cb(area, cr):
         style = area.get_style()
         Gdk.cairo_set_source_color(cr, style.white)
         cr.rectangle(0, 0, size, size)
         cr.fill()
         Gdk.cairo_set_source_color(cr, style.black)
         for r in range(boxcount_row):
             for c in range(boxcount_row):
                 if qr.isDark(r, c):
                     cr.rectangle((c + 2) * boxsize, (r + 2) * boxsize, boxsize, boxsize)
                     cr.fill()
     area = Gtk.DrawingArea()
     area.set_size_request(size, size)
     area.connect("draw", area_expose_cb)
     area.show()
     dialog = Gtk.Dialog(address, parent=self.window, flags=Gtk.DialogFlags.MODAL, buttons = ("ok",1))
     dialog.vbox.add(area)
     dialog.run()
     dialog.destroy()
コード例 #2
0
        def showqrcode(w, treeview, liststore):
            path, col = treeview.get_cursor()
            if not path: return
            address = liststore.get_value(liststore.get_iter(path), 0)
            qr = pyqrnative.QRCode(4, pyqrnative.QRErrorCorrectLevel.H)
            qr.addData(address)
            qr.make()
            boxsize = 7
            size = qr.getModuleCount() * boxsize

            def area_expose_cb(area, event):
                style = area.get_style()
                k = qr.getModuleCount()
                for r in range(k):
                    for c in range(k):
                        gc = style.black_gc if qr.isDark(r,
                                                         c) else style.white_gc
                        area.window.draw_rectangle(gc, True, c * boxsize,
                                                   r * boxsize, boxsize,
                                                   boxsize)

            area = gtk.DrawingArea()
            area.set_size_request(size, size)
            area.connect("expose-event", area_expose_cb)
            area.show()
            dialog = gtk.Dialog(address,
                                parent=self.window,
                                flags=gtk.DIALOG_MODAL
                                | gtk.DIALOG_NO_SEPARATOR,
                                buttons=("ok", 1))
            dialog.vbox.add(area)
            dialog.run()
            dialog.destroy()
コード例 #3
0
 def update_qr(self):
     if self.addr and not self.qr:
         for size in range(len(pyqrnative.QRUtil.PATTERN_POSITION_TABLE)): # [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]:
             try:
                 self.qr = pyqrnative.QRCode(size, pyqrnative.QRErrorCorrectLevel.L)
                 self.qr.addData(self.addr)
                 self.qr.make()
                 break
             except Exception:
                 self.qr=None
                 continue
         self.update()