当前位置:   article > 正文

生成二维码-Python带界面(FluentUI)_fluentui python

fluentui python

根据文字生成二维码

快捷生成二维码
通过输入任何内容,然后点击hello生成可以扫描二维码


pip install PyQt-Fluent-Widgets

pip install PyQt5

pip install "PyQt-Fluent-Widgets[full]" -i https://pypi.org/simple/
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
from tkinter import *
import qrcode
from PIL import Image,ImageTk

class Appwin(Frame):
    def __init__(self,master=None):
        Frame.__init__(self,master,width=300,height=400)
        self.pack()
        self.createWidgets()

    def createWidgets(self):
        self.nameInput = Entry(self)
        self.nameInput.pack()
        self.alertButton = Button(self,text="hello",command=self.genQrcode)
        self.alertButton.pack()
        self.label = Label(self)
        self.label.pack()

    def genQrcode(self):
        text = self.nameInput.get() or "没有输入"
        self.img = qrcode.make(text)
        self.tkImage = ImageTk.PhotoImage(image=self.img)
        self.label.config(image=self.tkImage)
        self.label.image=self.tkImage

root = Appwin()
root.master.title('二维码')
root.mainloop()

  • 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
# coding:utf-8
import sys
from qfluentwidgets import InfoBar,InfoBarPosition,ComboBox, LineEdit,FluentIcon
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QWidget
from qfluentwidgets import  PushButton



class Demo(QWidget):

    def __init__(self):
        super().__init__()
        self.setWindowTitle('二维码生成器')
        self.resize(400,400)
        #
        self.name = PushButton('填入你需要的二维码扫出文字', self)
        self.name.move(80, 10)
        self.name.resize(250, 35)
        #
        self.UsernameLineEdit = LineEdit(self)  
        self.UsernameLineEdit.move(100, 100)
        self.UsernameLineEdit.resize(200, 350)
        self.UsernameLineEdit.setClearButtonEnabled(True)
        #
        self.buttonSuccess= PushButton('生成', self)
        self.buttonSuccess.clicked.connect(self.GenerateInfoBar)
        self.buttonSuccess.move(100, 250)
        self.buttonSuccess.resize(200, 33)


    def GenerateInfoBar(self): 
        username = self.UsernameLineEdit.text()
        print(username)
        # 执行SQL语句
        InfoBar.success(
            title='生成',
            content="生成",
            orient=Qt.Horizontal,
            isClosable=True,
            position=InfoBarPosition.TOP,
            duration=2000,
            parent=self
        )





if __name__ == '__main__':
    # enable dpi scale
    QApplication.setHighDpiScaleFactorRoundingPolicy(
        Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
    QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)

    app = QApplication(sys.argv)
    w = Demo()
    w.show()
    app.exec_()
  • 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

更新时间:2024年1月20日

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/793412
推荐阅读
相关标签
  

闽ICP备14008679号