热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

python3+PyQt5图形项的自定义和交互python3实现pageDesigner应用程序

这篇文章主要为大家详细介绍了python3+PyQt5图形项的自定义和交互,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文通过Python3+PyQt5实现《python Qt Gui 快速编程》这本书的page Designer应用程序,采用QGraphicsView,QGraphicsScene,QGraphicsItem,这个程序包含有多个文本,图片和框的页面。有些图形类在PyQt5已过时,所以本代码改动幅度比较大。主要的类或方法的改变如下:

QMatrix==>QTransform
setMatrix==>setTransform
rotate ==> setRotation

本例中,由于event.delta()已过时,还重写了wheelEvent方法:

def wheelEvent(self, event):
 #factor = 1.41 ** (-event.delta() / 240.0) 
 #factor = 1.41 ** (-abs(event.startX()-event.y()) / 240.0)
 factor = event.angleDelta().y()/120.0
 if event.angleDelta().y()/120.0 > 0:
  factor=2
 else:
  factor=0.5
 self.scale(factor, factor)

为了保持代码可读行,增加了一个类:

class GraphicsPixmapItem(QGraphicsPixmapItem): #add by yangrongdong
 def __init__(self,pixmap):
 super(QGraphicsPixmapItem, self).__init__(pixmap)

本例中还有包含菜单的按钮:

 if text == "&Align":
 menu = QMenu(self)
 for text, arg in (
   ("Align &Left", Qt.AlignLeft),
   ("Align &Right", Qt.AlignRight),
   ("Align &Top", Qt.AlignTop),
   ("Align &Bottom", Qt.AlignBottom)):
   wrapper = functools.partial(self.setAlignment, arg)
   self.wrapped.append(wrapper)
   menu.addAction(text, wrapper)
  button.setMenu(menu)

本例中还针对QStyleOptionGraphicsItem.levelOfDetail已过时,改写如下:

option.levelOfDetailFromTransform(self.transform())

下面为完整的代码:

#!/usr/bin/env python3


import functools
import random
import sys
from PyQt5.QtCore import (QByteArray, QDataStream, QFile, QFileInfo,
    QIODevice, QPoint, QPointF, QRectF, Qt)
from PyQt5.QtWidgets import (QApplication, QDialog,
    QDialogButtonBox, QFileDialog, QFontComboBox,
    QGraphicsItem, QGraphicsPixmapItem,
    QGraphicsScene, QGraphicsTextItem, QGraphicsView, QGridLayout,
    QHBoxLayout, QLabel, QMenu, QMessageBox,QPushButton, QSpinBox,
    QStyle, QTextEdit, QVBoxLayout)
from PyQt5.QtGui import QFont,QCursor,QFontMetrics,QTransform,QPainter,QPen,QPixmap
from PyQt5.QtPrintSupport import QPrinter,QPrintDialog

MAC = True
try:
 from PyQt5.QtGui import qt_mac_set_native_menubar
except ImportError:
 MAC = False

#PageSize = (595, 842) # A4 in points
PageSize = (612, 792) # US Letter in points
PointSize = 10

MagicNumber = 0x70616765
FileVersion = 1

Dirty = False


class TextItemDlg(QDialog):

 def __init__(self, item=None, position=None, scene=None, parent=None):
 super(QDialog, self).__init__(parent)

 self.item = item
 self.position = position
 self.scene = scene

 self.editor = QTextEdit()
 self.editor.setAcceptRichText(False)
 self.editor.setTabChangesFocus(True)
 editorLabel = QLabel("&Text:")
 editorLabel.setBuddy(self.editor)
 self.fOntComboBox= QFontComboBox()
 self.fontComboBox.setCurrentFont(QFont("Times", PointSize))
 fOntLabel= QLabel("&Font:")
 fontLabel.setBuddy(self.fontComboBox)
 self.fOntSpinBox= QSpinBox()
 self.fontSpinBox.setAlignment(Qt.AlignRight|Qt.AlignVCenter)
 self.fontSpinBox.setRange(6, 280)
 self.fontSpinBox.setValue(PointSize)
 fOntSizeLabel= QLabel("&Size:")
 fontSizeLabel.setBuddy(self.fontSpinBox)
 self.buttOnBox= QDialogButtonBox(QDialogButtonBox.Ok|
      QDialogButtonBox.Cancel)
 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)

 if self.item is not None:
  self.editor.setPlainText(self.item.toPlainText())
  self.fontComboBox.setCurrentFont(self.item.font())
  self.fontSpinBox.setValue(self.item.font().pointSize())

 layout = QGridLayout()
 layout.addWidget(editorLabel, 0, 0)
 layout.addWidget(self.editor, 1, 0, 1, 6)
 layout.addWidget(fontLabel, 2, 0)
 layout.addWidget(self.fontComboBox, 2, 1, 1, 2)
 layout.addWidget(fontSizeLabel, 2, 3)
 layout.addWidget(self.fontSpinBox, 2, 4, 1, 2)
 layout.addWidget(self.buttonBox, 3, 0, 1, 6)
 self.setLayout(layout)


 self.fontComboBox.currentFontChanged.connect(self.updateUi)
 self.fontSpinBox.valueChanged.connect(self.updateUi)
 self.editor.textChanged.connect(self.updateUi)
 self.buttonBox.accepted.connect(self.accept)
 self.buttonBox.rejected.connect(self.reject)

 self.setWindowTitle("Page Designer - {0} Text Item".format(
  "Add" if self.item is None else "Edit"))
 self.updateUi()


 def updateUi(self):
 fOnt= self.fontComboBox.currentFont()
 font.setPointSize(self.fontSpinBox.value())
 self.editor.document().setDefaultFont(font)
 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(
  bool(self.editor.toPlainText()))


 def accept(self):
 if self.item is None:
  self.item = TextItem("", self.position, self.scene)
 fOnt= self.fontComboBox.currentFont()
 font.setPointSize(self.fontSpinBox.value())
 self.item.setFont(font)
 self.item.setPlainText(self.editor.toPlainText()) 
 self.item.update()
 global Dirty
 Dirty = True
 QDialog.accept(self)


class TextItem(QGraphicsTextItem):
 def __init__(self, text, position, scene,
   fOnt=QFont("Times", PointSize), matrix=QTransform()):
 super(TextItem, self).__init__(text)
 self.setFlags(QGraphicsItem.ItemIsSelectable|
   QGraphicsItem.ItemIsMovable)
 self.setFont(font)
 self.setPos(position)
 self.setTransform(matrix)
 scene.clearSelection()
 scene.addItem(self)
 self.setSelected(True)
 global Dirty
 Dirty = True


 def parentWidget(self):
 return self.scene().views()[0]


 def itemChange(self, change, variant):
 if change != QGraphicsItem.ItemSelectedChange:
  global Dirty
  Dirty = True
 return QGraphicsTextItem.itemChange(self, change, variant)


 def mouseDoubleClickEvent(self, event):
 dialog = TextItemDlg(self, self.parentWidget())
 dialog.exec_()



class GraphicsPixmapItem(QGraphicsPixmapItem): #add by yangrongdong
 def __init__(self,pixmap):
 super(QGraphicsPixmapItem, self).__init__(pixmap)


class BoxItem(QGraphicsItem):

 def __init__(self, position, scene, style=Qt.SolidLine,
   rect=None, matrix=QTransform()):
 super(BoxItem, self).__init__()
 self.setFlags(QGraphicsItem.ItemIsSelectable|
   QGraphicsItem.ItemIsMovable|
   QGraphicsItem.ItemIsFocusable)
 if rect is None:
  rect = QRectF(-10 * PointSize, -PointSize, 20 * PointSize,
    2 * PointSize)
 self.rect = rect
 self.style = style
 self.setPos(position)
 self.setTransform(matrix)
 scene.clearSelection()
 scene.addItem(self)
 self.setSelected(True)
 self.setFocus()
 global Dirty
 Dirty = True


 def parentWidget(self):
 return self.scene().views()[0]


 def boundingRect(self):
 return self.rect.adjusted(-2, -2, 2, 2)


 def paint(self, painter, option, widget):
 pen = QPen(self.style)
 pen.setColor(Qt.black)
 pen.setWidth(1)
 if option.state & QStyle.State_Selected:
  pen.setColor(Qt.blue)
 painter.setPen(pen)
 painter.drawRect(self.rect)


 def itemChange(self, change, variant):
 if change != QGraphicsItem.ItemSelectedChange:
  global Dirty
  Dirty = True
 return QGraphicsItem.itemChange(self, change, variant)


 def contextMenuEvent(self, event):
 wrapped = []
 menu = QMenu(self.parentWidget())
 for text, param in (
  ("&Solid", Qt.SolidLine),
  ("&Dashed", Qt.DashLine),
  ("D&otted", Qt.DotLine),
  ("D&ashDotted", Qt.DashDotLine),
  ("DashDo&tDotted", Qt.DashDotDotLine)):
  wrapper = functools.partial(self.setStyle, param)
  wrapped.append(wrapper)
  menu.addAction(text, wrapper)
 menu.exec_(event.screenPos())


 def setStyle(self, style):
 self.style = style
 self.update()
 global Dirty
 Dirty = True


 def keyPressEvent(self, event):
 factor = PointSize / 4
 changed = False
 if event.modifiers() & Qt.ShiftModifier:
  if event.key() == Qt.Key_Left:
  self.rect.setRight(self.rect.right() - factor)
  changed = True
  elif event.key() == Qt.Key_Right:
  self.rect.setRight(self.rect.right() + factor)
  changed = True
  elif event.key() == Qt.Key_Up:
  self.rect.setBottom(self.rect.bottom() - factor)
  changed = True
  elif event.key() == Qt.Key_Down:
  self.rect.setBottom(self.rect.bottom() + factor)
  changed = True
 if changed:
  self.update()
  global Dirty
  Dirty = True
 else:
  QGraphicsItem.keyPressEvent(self, event)


class GraphicsView(QGraphicsView):

 def __init__(self, parent=None):
 super(GraphicsView, self).__init__(parent)
 self.setDragMode(QGraphicsView.RubberBandDrag)
 self.setRenderHint(QPainter.Antialiasing)
 self.setRenderHint(QPainter.TextAntialiasing)


 def wheelEvent(self, event):
 #factor = 1.41 ** (-event.delta() / 240.0) 
 factor = event.angleDelta().y()/120.0
 if event.angleDelta().y()/120.0 > 0:
  factor=2
 else:
  factor=0.5
 self.scale(factor, factor)


class MainForm(QDialog):

 def __init__(self, parent=None):
 super(MainForm, self).__init__(parent)

 self.filename = ""
 self.copiedItem = QByteArray()
 self.pasteOffset = 5
 self.prevPoint = QPoint()
 self.addOffset = 5
 self.borders = []

 self.printer = QPrinter(QPrinter.HighResolution)
 self.printer.setPageSize(QPrinter.Letter)

 self.view = GraphicsView()
 self.scene = QGraphicsScene(self)
 self.scene.setSceneRect(0, 0, PageSize[0], PageSize[1])
 self.addBorders()
 self.view.setScene(self.scene)

 self.wrapped = [] # Needed to keep wrappers alive
 buttOnLayout= QVBoxLayout()
 for text, slot in (
  ("Add &Text", self.addText),
  ("Add &Box", self.addBox),
  ("Add Pi&xmap", self.addPixmap),
  ("&Align", None),
  ("&Copy", self.copy),
  ("C&ut", self.cut),
  ("&Paste", self.paste),
  ("&Delete...", self.delete),
  ("&Rotate", self.rotate),
  ("Pri&nt...", self.print_),
  ("&Open...", self.open),
  ("&Save", self.save),
  ("&Quit", self.accept)):
  button = QPushButton(text)
  if not MAC:
  button.setFocusPolicy(Qt.NoFocus)
  if slot is not None:
  button.clicked.connect(slot)
  if text == "&Align":
  menu = QMenu(self)
  for text, arg in (
   ("Align &Left", Qt.AlignLeft),
   ("Align &Right", Qt.AlignRight),
   ("Align &Top", Qt.AlignTop),
   ("Align &Bottom", Qt.AlignBottom)):
   wrapper = functools.partial(self.setAlignment, arg)
   self.wrapped.append(wrapper)
   menu.addAction(text, wrapper)
  button.setMenu(menu)
  if text == "Pri&nt...":
  buttonLayout.addStretch(5)
  if text == "&Quit":
  buttonLayout.addStretch(1)
  buttonLayout.addWidget(button)
 buttonLayout.addStretch()

 layout = QHBoxLayout()
 layout.addWidget(self.view, 1)
 layout.addLayout(buttonLayout)
 self.setLayout(layout)

 fm = QFontMetrics(self.font())
 self.resize(self.scene.width() + fm.width(" Delete... ") + 50,
   self.scene.height() + 50)
 self.setWindowTitle("Page Designer")


 def addBorders(self):
 self.borders = []
 rect = QRectF(0, 0, PageSize[0], PageSize[1])
 self.borders.append(self.scene.addRect(rect, Qt.yellow))
 margin = 5.25 * PointSize
 self.borders.append(self.scene.addRect(
  rect.adjusted(margin, margin, -margin, -margin),
  Qt.yellow))


 def removeBorders(self):
 while self.borders:
  item = self.borders.pop()
  self.scene.removeItem(item)
  del item


 def reject(self):
 self.accept()


 def accept(self):
 self.offerSave()
 QDialog.accept(self)


 def offerSave(self):
 if (Dirty and QMessageBox.question(self,
    "Page Designer - Unsaved Changes",
    "Save unsaved changes?",
    QMessageBox.Yes|QMessageBox.No) == 
  QMessageBox.Yes):
  self.save()


 def position(self):
 point = self.mapFromGlobal(QCursor.pos())
 if not self.view.geometry().contains(point):
  coord = random.randint(36, 144)
  point = QPoint(coord, coord)
 else:
  if point == self.prevPoint:
  point += QPoint(self.addOffset, self.addOffset)
  self.addOffset += 5
  else:
  self.addOffset = 5
  self.prevPoint = point
 return self.view.mapToScene(point)


 def addText(self):
 dialog = TextItemDlg(position=self.position(),
    scene=self.scene, parent=self)
 dialog.exec_()


 def addBox(self):
 BoxItem(self.position(), self.scene)


 def addPixmap(self):
 path = (QFileInfo(self.filename).path()
  if self.filename else ".")
 fname,filetype = QFileDialog.getOpenFileName(self,
  "Page Designer - Add Pixmap", path,
  "Pixmap Files (*.bmp *.jpg *.png *.xpm)")
 if not fname:
  return
 self.createPixmapItem(QPixmap(fname), self.position())


 def createPixmapItem(self, pixmap, position, matrix=QTransform()):
 item = GraphicsPixmapItem(pixmap)
 item.setFlags(QGraphicsItem.ItemIsSelectable|
   QGraphicsItem.ItemIsMovable)
 item.setPos(position)
 item.setTransform(matrix)
 self.scene.clearSelection()
 self.scene.addItem(item)
 item.setSelected(True)
 global Dirty
 Dirty = True
 return item


 def selectedItem(self):
 items = self.scene.selectedItems()
 if len(items) == 1:
  return items[0]
 return None


 def copy(self):
 item = self.selectedItem()
 if item is None:
  return
 self.copiedItem.clear()
 self.pasteOffset = 5
 stream = QDataStream(self.copiedItem, QIODevice.WriteOnly)
 self.writeItemToStream(stream, item)


 def cut(self):
 item = self.selectedItem()
 if item is None:
  return
 self.copy()
 self.scene.removeItem(item)
 del item


 def paste(self):
 if self.copiedItem.isEmpty():
  return
 stream = QDataStream(self.copiedItem, QIODevice.ReadOnly)
 self.readItemFromStream(stream, self.pasteOffset)
 self.pasteOffset += 5


 def setAlignment(self, alignment):
 # Items are returned in arbitrary order
 items = self.scene.selectedItems()
 if len(items) <= 1:
  return
 # Gather coordinate data
 leftXs, rightXs, topYs, bottomYs = [], [], [], []
 for item in items:
  rect = item.sceneBoundingRect()
  leftXs.append(rect.x())
  rightXs.append(rect.x() + rect.width())
  topYs.append(rect.y())
  bottomYs.append(rect.y() + rect.height())
 # Perform alignment
 if alignment == Qt.AlignLeft:
  xAlignment = min(leftXs)
  for i, item in enumerate(items):
  item.moveBy(xAlignment - leftXs[i], 0)
 elif alignment == Qt.AlignRight:
  xAlignment = max(rightXs)
  for i, item in enumerate(items):
  item.moveBy(xAlignment - rightXs[i], 0)
 elif alignment == Qt.AlignTop:
  yAlignment = min(topYs)
  for i, item in enumerate(items):
  item.moveBy(0, yAlignment - topYs[i])
 elif alignment == Qt.AlignBottom:
  yAlignment = max(bottomYs)
  for i, item in enumerate(items):
  item.moveBy(0, yAlignment - bottomYs[i])
 global Dirty
 Dirty = True


 def rotate(self):
 for item in self.scene.selectedItems():
  item.setRotation(item.rotation()+30)

 def delete(self):
 items = self.scene.selectedItems()
 if (len(items) and QMessageBox.question(self,
  "Page Designer - Delete",
  "Delete {0} item{1}&#63;".format(len(items),
  "s" if len(items) != 1 else ""),
  QMessageBox.Yes|QMessageBox.No) ==
  QMessageBox.Yes):
  while items:
  item = items.pop()
  self.scene.removeItem(item)
  del item
  global Dirty
  Dirty = True


 def print_(self):
 dialog = QPrintDialog(self.printer)
 if dialog.exec_():
  painter = QPainter(self.printer)
  painter.setRenderHint(QPainter.Antialiasing)
  painter.setRenderHint(QPainter.TextAntialiasing)
  self.scene.clearSelection()
  self.removeBorders()
  self.scene.render(painter)
  self.addBorders()


 def open(self):
 self.offerSave()
 path = (QFileInfo(self.filename).path()
  if self.filename else ".")
 fname,filetype = QFileDialog.getOpenFileName(self,
  "Page Designer - Open", path,
  "Page Designer Files (*.pgd)")
 if not fname:
  return
 self.filename = fname
 fh = None
 try:
  fh = QFile(self.filename)
  if not fh.open(QIODevice.ReadOnly):
  raise IOError(str(fh.errorString()))
  items = self.scene.items()
  while items:
  item = items.pop()
  self.scene.removeItem(item)
  del item
  self.addBorders()
  stream = QDataStream(fh)
  stream.setVersion(QDataStream.Qt_5_7)
  magic = stream.readInt32()
  if magic != MagicNumber:
  raise IOError("not a valid .pgd file")
  fileVersion = stream.readInt16()
  if fileVersion != FileVersion:
  raise IOError("unrecognised .pgd file version")
  while not fh.atEnd():
  self.readItemFromStream(stream)
 except IOError as e:
  QMessageBox.warning(self, "Page Designer -- Open Error",
   "Failed to open {0}: {1}".format(self.filename, e))
 finally:
  if fh is not None:
  fh.close()
 global Dirty
 Dirty = False


 def save(self):
 if not self.filename:
  path = "."
  fname,filetype = QFileDialog.getSaveFileName(self,
   "Page Designer - Save As", path,
   "Page Designer Files (*.pgd)")
  if not fname:
  return
  self.filename = fname
 fh = None
 try:
  fh = QFile(self.filename)
  if not fh.open(QIODevice.WriteOnly):
  raise IOError(str(fh.errorString()))
  self.scene.clearSelection()
  stream = QDataStream(fh)
  stream.setVersion(QDataStream.Qt_5_7)
  stream.writeInt32(MagicNumber)
  stream.writeInt16(FileVersion)
  for item in self.scene.items():
  self.writeItemToStream(stream, item)
 except IOError as e:
  QMessageBox.warning(self, "Page Designer -- Save Error",
   "Failed to save {0}: {1}".format(self.filename, e))
 finally:
  if fh is not None:
  fh.close()
 global Dirty
 Dirty = False


 def readItemFromStream(self, stream, offset=0):
 type = ""
 position = QPointF()
 matrix = QTransform()
 rotateangle=0#add by yangrongdong
 type=stream.readQString()
 stream >> position >> matrix
 if offset:
  position += QPointF(offset, offset)
 if type == "Text":
  text = ""
  fOnt= QFont()
  text=stream.readQString()
  stream >> font
  rotateangle=stream.readFloat()
  tx=TextItem(text, position, self.scene, font, matrix)
  tx.setRotation(rotateangle)
 elif type == "Box":
  rect = QRectF()
  stream >> rect
  style = Qt.PenStyle(stream.readInt16())
  rotateangle=stream.readFloat()
  bx=BoxItem(position, self.scene, style, rect, matrix)
  bx.setRotation(rotateangle)
 elif type == "Pixmap":
  pixmap = QPixmap()
  stream >> pixmap
  rotateangle=stream.readFloat()
  px=self.createPixmapItem(pixmap, position, matrix)
  px.setRotation(rotateangle)


 def writeItemToStream(self, stream, item):
 if isinstance(item, TextItem):
  stream.writeQString("Text")
  stream<

运行结果

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。


推荐阅读
  • 本文详细介绍了 PHP 中对象的生命周期、内存管理和魔术方法的使用,包括对象的自动销毁、析构函数的作用以及各种魔术方法的具体应用场景。 ... [详细]
  • 如何将TS文件转换为M3U8直播流:HLS与M3U8格式详解
    在视频传输领域,MP4虽然常见,但在直播场景中直接使用MP4格式存在诸多问题。例如,MP4文件的头部信息(如ftyp、moov)较大,导致初始加载时间较长,影响用户体验。相比之下,HLS(HTTP Live Streaming)协议及其M3U8格式更具优势。HLS通过将视频切分成多个小片段,并生成一个M3U8播放列表文件,实现低延迟和高稳定性。本文详细介绍了如何将TS文件转换为M3U8直播流,包括技术原理和具体操作步骤,帮助读者更好地理解和应用这一技术。 ... [详细]
  • 在Android平台中,播放音频的采样率通常固定为44.1kHz,而录音的采样率则固定为8kHz。为了确保音频设备的正常工作,底层驱动必须预先设定这些固定的采样率。当上层应用提供的采样率与这些预设值不匹配时,需要通过重采样(resample)技术来调整采样率,以保证音频数据的正确处理和传输。本文将详细探讨FFMpeg在音频处理中的基础理论及重采样技术的应用。 ... [详细]
  • 使用Maven JAR插件将单个或多个文件及其依赖项合并为一个可引用的JAR包
    本文介绍了如何利用Maven中的maven-assembly-plugin插件将单个或多个Java文件及其依赖项打包成一个可引用的JAR文件。首先,需要创建一个新的Maven项目,并将待打包的Java文件复制到该项目中。通过配置maven-assembly-plugin,可以实现将所有文件及其依赖项合并为一个独立的JAR包,方便在其他项目中引用和使用。此外,该方法还支持自定义装配描述符,以满足不同场景下的需求。 ... [详细]
  • Objective-C 中的委托模式详解与应用 ... [详细]
  • 在分析Android的Audio系统时,我们对mpAudioPolicy->get_input进行了详细探讨,发现其背后涉及的机制相当复杂。本文将详细介绍这一过程及其背后的实现细节。 ... [详细]
  • 本文详细介绍了MySQL数据库的基础语法与核心操作,涵盖从基础概念到具体应用的多个方面。首先,文章从基础知识入手,逐步深入到创建和修改数据表的操作。接着,详细讲解了如何进行数据的插入、更新与删除。在查询部分,不仅介绍了DISTINCT和LIMIT的使用方法,还探讨了排序、过滤和通配符的应用。此外,文章还涵盖了计算字段以及多种函数的使用,包括文本处理、日期和时间处理及数值处理等。通过这些内容,读者可以全面掌握MySQL数据库的核心操作技巧。 ... [详细]
  • MySQL Decimal 类型的最大值解析及其在数据处理中的应用艺术
    在关系型数据库中,表的设计与SQL语句的编写对性能的影响至关重要,甚至可占到90%以上。本文将重点探讨MySQL中Decimal类型的最大值及其在数据处理中的应用技巧,通过实例分析和优化建议,帮助读者深入理解并掌握这一重要知识点。 ... [详细]
  • 在Linux系统中避免安装MySQL的简易指南
    在Linux系统中避免安装MySQL的简易指南 ... [详细]
  • Android 构建基础流程详解
    Android 构建基础流程详解 ... [详细]
  • 在对WordPress Duplicator插件0.4.4版本的安全评估中,发现其存在跨站脚本(XSS)攻击漏洞。此漏洞可能被利用进行恶意操作,建议用户及时更新至最新版本以确保系统安全。测试方法仅限于安全研究和教学目的,使用时需自行承担风险。漏洞编号:HTB23162。 ... [详细]
  • 本文介绍了如何利用Shell脚本高效地部署MHA(MySQL High Availability)高可用集群。通过详细的脚本编写和配置示例,展示了自动化部署过程中的关键步骤和注意事项。该方法不仅简化了集群的部署流程,还提高了系统的稳定性和可用性。 ... [详细]
  • 在命令行环境中,通过输入 `python` 命令进入 Python 交互模式后,用户可能会遇到如何正确退出的问题。本文详细介绍了多种退出 Python 交互模式的方法,包括使用 `exit()` 函数、 `quit()` 函数以及直接输入 `Ctrl+D` 等方式,帮助用户在不同场景下灵活选择合适的退出方法。 ... [详细]
  • 本文探讨了资源访问的学习路径与方法,旨在帮助学习者更高效地获取和利用各类资源。通过分析不同资源的特点和应用场景,提出了多种实用的学习策略和技术手段,为学习者提供了系统的指导和建议。 ... [详细]
  • 本文探讨了基于点集估算图像区域的Alpha形状算法在Python中的应用。通过改进传统的Delaunay三角剖分方法,该算法能够生成更加灵活和精确的形状轮廓,避免了单纯使用Delaunay三角剖分时可能出现的过大三角形问题。这种“模糊Delaunay三角剖分”技术不仅提高了形状的准确性,还增强了对复杂图像区域的适应能力。 ... [详细]
author-avatar
烟为你吸_811
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有