DigDeep

GUI Panel for Log trace

9 posts in this topic

#1 ·  Posted

I wanted a GUI Panel that I can use for getting the live log traces.

Like, when my script writes the log line inside the log file, the GUI Panel should also show the same line... I can later think of making it visible or not.

Wondering if this is something already discussed in earlier forum and I can get some help with...

Thanks.

Share this post


Link to post
Share on other sites



#2 ·  Posted

Hi @DigDeep:)

Have you already wrote some lines of code which we can see? :)

You're trying to see the lines which are wrote in the log file, isn't it? :)

It should be so difficult... You could try something like this:

; You just have to create an Edit control ( or a ListView control ), in order to show the lines of your file in your GUI...
; If you choose the Edit control, you could just simply try this:

Local $strLogLine = "Some text wrote in the log" & @CRLF

GUICtrlSetData($strLogLine, $editLogLines, 1)

So, based on how do you write lines in your log file, you can see those lines in your GUI...

Just put GUICtrlSetData() after every write in your log file, and you're done :)

Hope that helps :)


Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

Share this post


Link to post
Share on other sites

#3 ·  Posted

#include <GUIConstants.au3>

Global $hMain = GUICreate("", 420, 220)
Global $edtConsole = GUICtrlCreateEdit("", 10, 10, 400, 200)

GUISetState(@SW_SHOW, $hMain)

ConsoleOut("Loaded form" & @CRLF)
ConsoleOut("Wrote to console" & @CRLF)
LogOut("Writing to log file" & @CRLF)

While(True)
    Switch (GUIGetMsg())
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func ConsoleOut($sMsg)
    GUICtrlSetData($edtConsole, GUICtrlRead($edtConsole) & $sMsg)
    LogOut($sMsg)
EndFunc

Func LogOut($sMsg)
    FileWrite(@ScriptDir & "\Log.txt", $sMsg)
EndFunc

A full example of trying to write to a console before writing to the log file

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi, first of all sorry for getting back as I was away for sometime.

@FrancescoDiMuro and @InunoTaishou , I was looking at @weaponx code shown below for sliding In & Out Form.

This is something I was looking for since sometime now and I think I can use it as per my need. But I need some changes here.

1. Instead of sliding bottom, I wanted to slide Right side.

2. I have a blank GUI Form below that I want to use it as Parent and the sliding Panel to be attached in the Parent GUI. I don't want a button click to pop-out the sliding GUI.

Could you please help with this?

I have attached a sample snapshot.

 

Sliding GUI panel to be used as child

#include <GUIConstants.au3>

    Opt("GUIOnEventMode", 1)

    Global $startWidth = 200, $startHeight = 200

    Global $endWidth = $startWidth, $endHeight = 400
    ;~ Global $endHeight = $startHeight, $endWidth = 400

    GUICreate("My GUI", $startHeight, $startWidth) ; will create a dialog box that when displayed is centered
    GUISetOnEvent($GUI_EVENT_CLOSE, "Close")

    GUISetState(@SW_SHOW) ; will display an empty dialog box

    ;Draw Expand/Contract buttons on top of each other (hide Contract button initially)
    $buttonExpand = GUICtrlCreateButton("Expand", 70, 170, 60, 20)
    GUICtrlSetOnEvent($buttonExpand, "expand")

    $buttonContract = GUICtrlCreateButton("Contract", 70, 170, 60, 20)
    GUICtrlSetState($buttonContract, $GUI_HIDE)
    GUICtrlSetOnEvent($buttonContract, "contract")


    ; Run the GUI until the dialog is closed
    While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
    ExitLoop
    EndSwitch
    WEnd


    Func expand()
    ;Expand vertically, 6 pixels at a time
    For $X = $startHeight To $endHeight Step 6
    WinMove("", "", Default, Default, $startHeight, $X)
    ;Sleep 0=Fastest, 5=Slowest
    Sleep(PixelsToPercent($startHeight, $X, $endHeight) * 5)
    Next
    GUICtrlSetState($buttonExpand, $GUI_HIDE)
    GUICtrlSetState($buttonContract, $GUI_SHOW)
    EndFunc   ;==>expand

    Func contract()
    ;Contract vertically, 6 pixels at a time
    For $X = $endHeight To $startHeight Step -6
    WinMove("", "", Default, Default, $startHeight, $X)
    ;Sleep 0=Fastest, 5=Slowest
    Sleep(PixelsToPercent($startHeight, $X, $endHeight) * 5)
    Next
    GUICtrlSetState($buttonExpand, $GUI_SHOW)
    GUICtrlSetState($buttonContract, $GUI_HIDE)
    EndFunc   ;==>contract

    ;Convert pixel width or height to relative percentage difference (Min = 0%, Max = 100%)
    Func PixelsToPercent($min, $current, $max)
    ;Return value from 0-1
    Return ($current - $min) / ($max - $min)
    EndFunc   ;==>PixelsToPercent

    Func Close()
    Exit
    EndFunc   ;==>Close

 

Blank GUI Form to be used as Parent.

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 1478, 831, 278, 111)
$Edit1 = GUICtrlCreateEdit("", 1008, 0, 467, 830)
GUICtrlSetData(-1, "")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Sample.jpg

Edited by DigDeep

Share this post


Link to post
Share on other sites

#6 ·  Posted

@DigDeep

Happy to see you here again :)

And now, what are you trying to do? 

I am more familiar ( and I prefer more ) with OnEventMode GUIs instead of continuousely "get a message" from the GUI...

If you tell me what you're trying to do, I'll try to help you as much as I can :)


Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

Share this post


Link to post
Share on other sites

#7 ·  Posted

Hi @FrancescoDiMuro good to see you too.

What I am trying out is to have a Parent GUI. Click on a button somewhere on the Parent GUI which will slide down the Child GUI which will have the GUIEdit that I can use to show some texts.

The above child example is for sliding left and right, But I need something for sliding down.

Share this post


Link to post
Share on other sites

#8 ·  Posted

@DigDeep

Now it's clearer :)

Are you trying to slide the Child GUI on your screen, pressing buttons on the Parent GUI?

On the whole screen or in the limits of the Parent GUI height? :)


Click here to see my signature:

Spoiler

I will always thank you for the time you spent for me.
I'm here to ask, and from your response, I'd like to learn.
By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

Share this post


Link to post
Share on other sites

#9 ·  Posted

yes, pressing a button anywhere in Parent GUI getting a child GUI sliding down and then going back up and hiding will be good. I don't think the Parent GUI itself extending down will be ideal.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now