前些天用pyqt5比葫芦画瓢绘制了个下面的表格,下来的事情就搞不定了。感觉比较难啊。
看到一些有参考价值的帖子:
一、
GDI+绘制曲线图并自动更新
ashfinal 发表于 2012-5-28 19:05 http://www.autoitx.com/images/common/back.gif
二、
帮助文档里的进度条样例,其中进度条的参数可以设置为变量,这样嵌入到循环里就应该可以改变进度条的形状、大小和颜色了吧?
#include <GUIConstants.au3>
#include <MsgBoxConstants.au3>
GUICreate("我的 GUI 之进度条",220,100, 100,200)
$progressbar1 = GUICtrlCreateProgress (10,10,200,20)
$progressbar2 = GUICtrlCreateProgress (10,40,200,20,$PBS_SMOOTH)
$button = GUICtrlCreateButton ("开始",75,70,70,20)
GUISetState ()
$wait = 20; 进度条没进一个单位就等20毫秒
$s = 0; 用于保存进度条的滑块位置
do
$msg = GUIGetMsg()
If $msg = $button Then
GUICtrlSetData ($button,"暂停")
For $i = $s To 100
If GUICtrlRead($progressbar1) = 50 Then Msgbox(0,"信息","已完成一半...", 1)
$m = GUIGetMsg ()
If $m = -3 Then ExitLoop
If $m = $button Then
GUICtrlSetData ($button,"继续")
$s = $i;保存当前滑块位置到 $s
ExitLoop
Else
$s=0
GUICtrlSetData ($progressbar1,$i)
GUICtrlSetData ($progressbar2,(100 - $i))
Sleep($wait)
EndIf
Next
if $i >100 then
; ;s=0
GUICtrlSetData ($button,"开始")
endif
EndIf
until $msg = $GUI_EVENT_CLOSE 在控件上绘制图形的参考帖子:
http://www.autoitx.com/forum.php?mod=viewthread&tid=38760&highlight=%CD%BC%D0%CE
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
GUICreate('图片背景按钮例子')
$Button1 = GUICtrlCreateButton('按钮', 150, 270, 100, 25)
GUICtrlCreatePic(RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir') & "\Examples\GUI\msoobe.jpg", 0, 0, 400, 400, $WS_CLIPSIBLINGS, $GUI_WS_EX_PARENTDRAG)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1
MsgBox(0, 0, 'ok')
EndSwitch
WEnd
http://www.autoitx.com/forum.php?mod=viewthread&tid=38819&highlight=%CD%BC%D0%CE
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
FileInstall("Black.she", @TempDir & "\Black.she", 1)
FileInstall("Skin.dll", @TempDir & "\Skin.dll", 1)
$skins = @TempDir & "\Black.she"
$dll = DllOpen(@TempDir & "\Skin.dll")
DllCall($dll, "int", "SkinH_AttachEx", "str", $skins, "str", "mhgd")
DllCall($dll, "int", "SkinH_SetAero", "int", 1)
$Form1 = GUICreate("平直度判断工具", 905, 585, @DesktopWidth / 2 - 452, @DesktopHeight / 2 - 292)
$ButtonDown = GUICtrlCreateButton("下一个", 257, 392, 65, 33)
$Graphic1 = GUICtrlCreateGraphic(384, 24, 500, 400)
GUICtrlSetGraphic(-1, $GUI_GR_RECT, 0, 0, 500, 400)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
GDI+绘制曲线图并自动更新
http://www.autoitx.com/forum.php?mod=viewthread&tid=32594&extra=&highlight=%D7%D4%B6%AF%B8%FC%D0%C2&page=1 回复 11# joint
https://www.autoitscript.com/forum/topic/70483-listview_progress/ 回复joint
lpxx 发表于 2017-6-25 12:54 http://www.autoitx.com/images/common/back.gif
谢谢。看了几个你的帖子,水平挺高,请多帮忙啊。谢谢。 本帖最后由 joint 于 2017-7-4 16:55 编辑
昨天晚上翻老帖翻到2点多,发现了不少感觉很不错的帖子,做个记号,得好好学习。
不过,现在是基本上全看不懂,不知道怎样才能快速入手?有那位能先给个注释吗?我出点辛苦费:
請問如何讓 array 顯示在GUI裡面? 然後每秒更新一次arrayhttp://www.autoitx.com/forum.php?mod=viewthread&tid=52240&from=favorites
TAB内的ListView显示慢速原因http://www.autoitx.com/forum.php?mod=viewthread&tid=2088&highlight=
GDI+绘制曲线图并自动更新http://www.autoitx.com/forum.php?mod=viewthread&tid=32594&from=favorites
在ListView上设置进度条http://www.autoitx.com/forum.php?mod=viewthread&tid=3028&from=favorites
画图UDF函数http://www.autoitx.com/forum.php?mod=viewthread&tid=9988&from=favorites
载入条http://www.autoitx.com/forum.php?mod=viewthread&tid=53167&highlight=GDI 这些看起来很棒啊:
;coded by UEZ build 2014-03-04, idea taken from http://codepen.io/Fahrenheit/pen/Kbyxu
;AutoIt v3.3.9.21 or higher needed!
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
_GDIPlus_Startup()
Global Const $STM_SETIMAGE = 0x0172; $IMAGE_BITMAP = 0
Global $iW = 400, $iH = 150
Global Const $hGUI = GUICreate("Multi Color Loader", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()
Global $hHBmp_BG, $hB, $iPerc = 0, $iSleep = 30, $s = 0, $t, $m = 0, $iPerc = 0
GUIRegisterMsg($WM_TIMER, "PlayAnim")
DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0)
Do ;coded by UEZ build 2014-04-28, idea taken from http://codepen.io/noahblon/pen/KwiFg
;AutoIt v3.3.9.21 or higher needed!
#include <Array.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
_GDIPlus_Startup()
Global Const $STM_SETIMAGE = 0x0172; $IMAGE_BITMAP = 0
Global $iW = 600, $iH = 300
Global Const $hGUI = GUICreate("Carousel", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()
Global $hHBmp_BG, $hB, $iPerc = 0, $iSleep = 10, $iPerc = 0
GUIRegisterMsg($WM_TIMER, "PlayAnim")
DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0)
Do
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
GUIRegisterMsg($WM_TIMER, "")
_WinAPI_DeleteObject($hHBmp_BG)
_GDIPlus_Shutdown()
GUIDelete()
Exit
EndSwitch
Until False
Func PlayAnim()
$hHBmp_BG = _GDIPlus_Carousel($iPerc, $iW, $iH)
$hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG)
If $hB Then _WinAPI_DeleteObject($hB)
_WinAPI_DeleteObject($hHBmp_BG)
$iPerc += 0.2
If $iPerc > 99.9 Then $iPerc = 0
EndFunc ;==>PlayAnim
Func _GDIPlus_Carousel($fPerc, $iW, $iH, $bHBitmap = True)
Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hGfx, 4 + (@OSBuild > 5999))
;~ _GDIPlus_GraphicsSetTextRenderingHint($hGfx, 3)
_GDIPlus_GraphicsSetPixelOffsetMode($hGfx, 4)
_GDIPlus_GraphicsClear($hGfx, 0xFFFFFFFF)
Local Const $iUB = 4
Local $aColors[$iUB] = [, , , ]
Local Const $fRadius = 50, $fMid = ($iW - $fRadius) / 2
Local Const $hBrush = _GDIPlus_BrushCreateSolid(), $hPen = _GDIPlus_PenCreate(0x80000000)
Local Const $hPath1 = _GDIPlus_PathCreate(), $hPath2 = _GDIPlus_PathCreate()
Local $hRegion1, $hRegion2, $fPenSize, $i
Local Static $fSpeed
For $i = 0 To $iUB - 1
$aColors[$i] = -Sin($fSpeed + $i * 1.570796) * 15 ;z coordinate, 1.570796 = Pi/2 = 90?= 360?/ 4
$aColors[$i] = $fMid + Cos($fSpeed + $i * 1.570796) * 80 ;x coordinate
Next
_ArraySort($aColors, 0, 0, 0, 2) ;sort z-axis
For $i = 0 To $iUB - 1
$fPenSize = $aColors[$i] / 20 + 1.1
_GDIPlus_PenSetWidth($hPen, $fPenSize)
_GDIPlus_BrushSetSolidColor($hBrush, 0x80E0E0E0) ;shadow color
_GDIPlus_GraphicsFillEllipse($hGfx, $aColors[$i], ($iH - $fRadius) / 2 + 10 + $fRadius + $aColors[$i], $fRadius + $aColors[$i], ($fRadius + $aColors[$i]) / 4, $hBrush)
_GDIPlus_PathAddEllipse($hPath1, $aColors[$i], ($iH - $fRadius) / 2, $fRadius + $aColors[$i], $fRadius + $aColors[$i])
_GDIPlus_PathAddEllipse($hPath2, $aColors[$i] + $fPenSize - 5 - $aColors[$i] / 10, ($iH - $fRadius) / 2 - $fPenSize - 5 - $aColors[$i] / 10, $fRadius + $aColors[$i], $fRadius + $aColors[$i])
$hRegion1 = _GDIPlus_RegionCreateFromPath($hPath1)
$hRegion2 = _GDIPlus_RegionCreateFromPath($hPath2)
_GDIPlus_RegionCombineRegion($hRegion1, $hRegion2, 1) ;combine lighter circle with darker circle
_GDIPlus_BrushSetSolidColor($hBrush, $aColors[$i]) ;lighter ball color
_GDIPlus_GraphicsFillPath($hGfx, $hPath1, $hBrush)
_GDIPlus_BrushSetSolidColor($hBrush, $aColors[$i]) ;darker ball color
_GDIPlus_GraphicsFillRegion($hGfx, $hRegion1, $hBrush)
_GDIPlus_GraphicsDrawPath($hGfx, $hPath1, $hPen) ;draw circle frame
_GDIPlus_RegionDispose($hRegion1)
_GDIPlus_RegionDispose($hRegion2)
_GDIPlus_PathReset($hPath1)
_GDIPlus_PathReset($hPath2)
Next
$fSpeed += 0.0261799
Local $iW_Progressbar = $iW / 2 + 4
_GDIPlus_PenSetColor($hPen, 0xD048D1CC)
_GDIPlus_GraphicsDrawRect($hGfx, ($iW - $iW_Progressbar) / 2, $iH - 50, $iW_Progressbar, 14, $hPen)
_GDIPlus_BrushSetSolidColor($hBrush, 0xFFAFEEEE)
_GDIPlus_GraphicsFillRect($hGfx, ($iW - $iW_Progressbar) / 2 + 2, $iH - 48, $fPerc * ($iW_Progressbar - 4) / 100, 10, $hBrush)
_GDIPlus_PenSetColor($hPen, 0x20000000)
_GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $iW, $iH, $hPen) ;draw window frame
_GDIPlus_PathDispose($hPath1)
_GDIPlus_PathDispose($hPath2)
_GDIPlus_PenDispose($hPen)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hGfx)
If $bHBitmap Then
Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
_GDIPlus_BitmapDispose($hBitmap)
Return $hHBITMAP
EndIf
Return $hBitmap
EndFunc 余辉效果
;by Eukalyptus
;AutoIt v3.3.9.21 or higher needed!
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
_GDIPlus_Startup()
Global Const $STM_SETIMAGE = 0x0172
Global $iW = 380, $iH = 260
Global $hGui = GUICreate("Loading", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
Global $cPic = GUICtrlCreatePic("", 0, 0, $iW, $iH)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()
Global $hHBmp_BG, $hB, $iPerc = 0, $iSleep = 20, $fPower = 4
GUIRegisterMsg($WM_TIMER, "PlayAnim")
DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGui, "int", 0, "int", $iSleep, "int", 0)
Do
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
GUIRegisterMsg($WM_TIMER, "")
_WinAPI_DeleteObject($hHBmp_BG)
_GDIPlus_Shutdown()
GUIDelete()
Exit
EndSwitch
Until False
Func PlayAnim()
$hHBmp_BG = _GDIPlus_SpinningAndGlowing($iPerc, $iW, $iH)
$hB = GUICtrlSendMsg($cPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG)
If $hB Then _WinAPI_DeleteObject($hB)
_WinAPI_DeleteObject($hHBmp_BG)
$iPerc += $fPower
EndFunc ;==>PlayAnim
Func _GDIPlus_SpinningAndGlowing($fProgress, $iW, $iH, $iColor = 0xFF6644FF, $fSize = 80, $iCnt = 24, $fDM = 24, $fScale = 3, $iGlowCnt = 6)
Local $hBmp = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBmp)
_GDIPlus_GraphicsSetSmoothingMode($hGfx, 2)
_GDIPlus_GraphicsClear($hGfx, 0xFF141414)
Local $iOff = $iCnt * Mod($fProgress, 100) / 100
Local $fCX = $iW * 0.5
Local $fCY = $iH * 0.5
Local $hPath = _GDIPlus_PathCreate()
_GDIPlus_PathAddEllipse($hPath, -$fDM * 0.5, -$fDM * 0.5, $fDM, $fDM)
Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
_GDIPlus_PathBrushSetCenterColor($hBrush, $iColor)
_GDIPlus_PathBrushSetSurroundColor($hBrush, 0)
_GDIPlus_PathBrushSetGammaCorrection($hBrush, True)
Local $aBlend = []
$aBlend = 0
$aBlend = 0
$aBlend = BitOR(BitAND($iColor, 0x00FFFFFF), 0x1A000000)
$aBlend = 0.78
$aBlend = BitOR(BitAND($iColor, 0x00FFFFFF), 0xFF000000)
$aBlend = 0.88
$aBlend = 0xFFFFFFFF
$aBlend = 1
_GDIPlus_PathBrushSetPresetBlend($hBrush, $aBlend)
Local $fS
Local Const $cPI = ATan(1) * 4
For $i = 0 To $iCnt - 1
$fS = Sin($cPI * Log(1.4 + Mod($iOff + $i, $iCnt) / $iGlowCnt) / Log(4))
If $fS < 0 Then $fS = 0
$fS = 1 + $fScale * $fS
_GDIPlus_GraphicsResetTransform($hGfx)
_GDIPlus_GraphicsScaleTransform($hGfx, $fS, $fS, True)
_GDIPlus_GraphicsTranslateTransform($hGfx, -$fSize, 0, True)
_GDIPlus_GraphicsScaleTransform($hGfx, 1.2, 1, False)
_GDIPlus_GraphicsRotateTransform($hGfx, -360 / $iCnt * $i, True)
_GDIPlus_GraphicsTranslateTransform($hGfx, $fCX, $fCY, True)
_GDIPlus_GraphicsFillPath($hGfx, $hPath, $hBrush)
Next
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_PathDispose($hPath)
Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp)
_GDIPlus_GraphicsDispose($hGfx)
_GDIPlus_BitmapDispose($hBmp)
Return $hHBITMAP
EndFunc ;==>_GDIPlus_SpinningAndGlowing
页:
1
[2]