houstonl3 Posted April 6, 2015 Posted April 6, 2015 I have a GUI that contains around 11 buttons that make my job easier, and one of them calculates a percentage. As of now, I have that percentage displaying in a label also in the GUI, but I'd like for it to update the percentage ON THE BUTTON TEXT instead of having to use a label. This may not be possible, because all of the places I've tried it in, in my code, disables the button once it changes the text of the button. Is there any way to do this? I hope this isn't too confusing. I can provide code if needed, however, I didn't because it doesn't seem necessary for this type of issue. Any help is appreciated. Thanks,
ahmet Posted April 6, 2015 Posted April 6, 2015 This works #include <GUIConstantsEx.au3> $hMain=GUICreate("test") $idButton=GUICtrlCreateButton("Calculate",10,10,100) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idButton GUICtrlSetData($idButton,Random(0,1)) EndSwitch WEnd Posting your code might help.
Solution l3ill Posted April 6, 2015 Solution Posted April 6, 2015 (edited) You can change the Button text by using GUICtrlSetData( $buttonID, "Something") As mentioned above^^^ Just place it somewhere in the function that should update it. Replace "Something" with your Percentage variable. Edited April 6, 2015 by l3ill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
iamtheky Posted April 6, 2015 Posted April 6, 2015 as the above, with a timer, showing that the button still works fine #include <GUIConstantsEx.au3> $hMain=GUICreate("test") $idButton=GUICtrlCreateButton("Calculate",10,10,100) GUISetState() $timer = timerinit() While 1 $sTime = round(timerdiff($timer)) GUICtrlSetData($idButton, $sTime) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idButton msgbox(0, '' , $sTime) EndSwitch sleep(10) WEnd ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
houstonl3 Posted April 6, 2015 Author Posted April 6, 2015 Thanks guys. Sorry, I kind of feel like a noob now. I'm a little new to this. I really appreciate it though.
Moderators Melba23 Posted April 6, 2015 Moderators Posted April 6, 2015 houstonl3, Sorry, I kind of feel like a noob nowNo need to apologise - we were all at that point once. As a newcomer to AutoIt, reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at this excellent tutorial - you will find other tutorials in the Wiki (the link is at the top of the page). M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now