Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Miniwindows ➜ miniwindows--python

miniwindows--python

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2 

Posted by LupusFatalis   (154 posts)  Bio
Date Reply #15 on Sun 03 May 2009 03:34 AM (UTC)

Amended on Mon 04 May 2009 01:59 PM (UTC) by David Haley

Message
Ok... I Have a piece of code I think is psuedo worthy of actually sharing... as well as a few improvements I'd like to make but have no idea as to how to do so.
LinesList = []

def OnPluginConnect():
	win = world.GetPluginID

	temp = world.GetWorldWindowPosition.split(',')
	winHeight = int((int(temp[3]) - int(temp[1])) * 0.25)
	winWidth = int(temp[2]) - int(temp[0]) - 29

	world.WindowCreate (win, 0, 0, winWidth, winHeight, 4, 0, 0x000000)
	world.WindowRectOp (win, 1, 1, 1, -1, -1, 0x0000FF, 0xFFFFFF)
	world.WindowRectOp (win, 1, 2, 2, -2, -2, 0x0000FF, 0xFFFFFF)

	world.WindowShow (win, 1)

def OnPluginDisconnect():
	win = world.GetPluginID
	world.WindowShow (win, 0)


def OnPluginClose():
	win = world.GetPluginID
	world.WindowShow (win, 0)


def OnPluginDisable():
	win = world.GetPluginID
	world.WindowShow (win, 0)


def OnPluginEnable():
	win = world.GetPluginID

	world.WindowCreate (win, 0, 0, winWidth, winHeight, 4, 0, 0x000000)
	world.WindowRectOp (win, 1, 1, 1, -1, -1, 0x0000FF, 0xFFFFFF)
	world.WindowRectOp (win, 1, 2, 2, -2, -2, 0x0000FF, 0xFFFFFF)

	world.WindowShow (win, 1)


def OnPluginWorldOutputResized():
	win = world.GetPluginID

	temp = world.GetWorldWindowPosition.split(',')
	winHeight = int((int(temp[3]) - int(temp[1])) * 0.25)
	winWidth = int(temp[2]) - int(temp[0]) - 29

	world.WindowFont (win, 'body', 'Dina', 10, 0, 0, 0, 0, 1, 0)
	fontHeight = int(world.WindowFontInfo(win, 'body', 1))
	mLines = winHeight / fontHeight
	
	world.WindowCreate (win, 0, 0, winWidth, winHeight, 4, 0, 0x000000)
	world.WindowRectOp (win, 1, 1, 1, -1, -1, 0x0000FF, 0x0000FF)
	world.WindowRectOp (win, 1, 2, 2, -2, -2, 0x0000FF, 0x0000FF)

	winTMargin = 5
	winLMargin = 5

	for i in range(0, len(LinesList)):
		localTMargin = winTMargin + 16*i
		world.WindowText (win, 'body', LinesList[i], winLMargin, localTMargin, 0, 0, 0xCCCCCC, 1)

	world.WindowShow (win, 1)


def OnPluginScreendraw(type, log, line):
	win = world.GetPluginID

	temp = world.GetWorldWindowPosition.split(',')
	winHeight = int((int(temp[3]) - int(temp[1])) * 0.25)
	winWidth = int(temp[2]) - int(temp[0]) - 29

	world.WindowFont (win, 'body', 'Dina', 10, 0, 0, 0, 0, 1, 0)
	fontHeight = int(world.WindowFontInfo(win, 'body', 1))
	mLines = winHeight / fontHeight
	
	if len(LinesList) >= mLines:
		LinesList.pop(0)
		world.WindowRectOp (win, 1, 2, 2, -2, -2, 0x0000FF, 0x0000FF)
	LinesList.append (line)

	world.WindowCreate (win, 0, 0, winWidth, winHeight, 4, 0, 0x000000)
	world.WindowRectOp (win, 1, 1, 1, -1, -1, 0x0000FF, 0x0000FF)
	world.WindowRectOp (win, 1, 2, 2, -2, -2, 0x0000FF, 0x0000FF)

	winTMargin = 5
	winLMargin = 5

	for i in range(0, len(LinesList)):
		localTMargin = winTMargin + 16*i
		world.WindowText (win, 'body', LinesList[i], winLMargin, localTMargin, 0, 0, 0xCCCCCC, 1)

	world.WindowShow (win, 1)
	return 0


It will display the most recent lines. Any number of lines based on a percentage of your screen. Now... Here is where things get dicey. The world screen size isn't updated when maximized, any idea how to extract that, so as to use it in the resizing function here.

And the other improvement I want to make is. I want this window to be displayed ONLY when I am scrolling back in the main window. Any ideas?



(EDIT by David: I took the liberty of fixing the [i] tags in the post so as to not italicize the entire post.)
Top

Posted by LupusFatalis   (154 posts)  Bio
Date Reply #16 on Tue 05 May 2009 11:05 PM (UTC)

Amended on Tue 05 May 2009 11:07 PM (UTC) by LupusFatalis

Message
Ok, I found 2 bugs in it. If you resize the window, your miniwindow can become lagged as the list has more things than can be displayed. Also, when loading at first, for some reason the world.WindowFontInfo(win, 'body', 1) will register as None... so an if statement has been included to account for that. I still want to preform the aforementioned upgrades if anyone has any ideas as to how. Here is the new code.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Friday, April 24, 2009, 7:01 PM -->
<!-- MuClient version 4.40 -->

<!-- Plugin "Most_Recent_Text" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Most_Recent_Text"
   id="5857d039eaa8c30c4c813ec8"
   language="Python"
   purpose="Miniwindow displaying up to date information while scrolling back the main window"
   date_written="2009-04-24 19:01:01"
   requires="4.40"
   version="1.0"
   >

</plugin>


<!--  Get our standard constants -->

<include name="constants.pys"/>

<!--  Script  -->


<script>
<![CDATA[

LinesList = []
winTMargin = 1
winLMargin = 1
win = world.GetPluginID
fontHeight = 16

def OnPluginDisconnect():
	world.WindowShow (win, 0)


def OnPluginClose():
	world.WindowShow (win, 0)


def OnPluginDisable():
	world.WindowShow (win, 0)


def OnPluginEnable():
	temp = world.GetWorldWindowPosition.split(',')
	winHeight = int((int(temp[3]) - int(temp[1])) * 0.25)
	winWidth = int(temp[2]) - int(temp[0]) - 29

	world.WindowCreate (win, 0, 0, winWidth, winHeight, 4, 0, 0x000000)
	world.WindowRectOp (win, 2, 1, 1, -1, -1, 0x000000, 0x000000)
	world.WindowLine (win, 0, winHeight, winWidth, winHeight, 0xCCCCCC, 0, 5)

	world.WindowShow (win, 1)


def OnPluginWorldOutputResized():
	temp = world.GetWorldWindowPosition.split(',')
	winHeight = int((int(temp[3]) - int(temp[1])) * 0.25)
	winWidth = int(temp[2]) - int(temp[0]) - 29

	world.WindowFont (win, 'body', 'Dina', 10, 0, 0, 0, 0, 1, 0)
	if not world.WindowFontInfo(win, 'body', 1):
		fontHeight = 16
	else:
		fontHeight = int(world.WindowFontInfo(win, 'body', 1))

	mLines = winHeight / fontHeight
	
	while len(LinesList) > mLines:
		LinesList.pop(0)

	DisplayText()
	
def OnPluginScreendraw(type, log, line):
	temp = world.GetWorldWindowPosition.split(',')
	winHeight = int((int(temp[3]) - int(temp[1])) * 0.25)
	winWidth = int(temp[2]) - int(temp[0]) - 29

	world.WindowFont (win, 'body', 'Dina', 10, 0, 0, 0, 0, 1, 0)
	if not world.WindowFontInfo(win, 'body', 1):
		fontHeight = 16
	else:
		fontHeight = int(world.WindowFontInfo(win, 'body', 1))

	mLines = winHeight / fontHeight
	
	if len(LinesList) >= mLines:
		LinesList.pop(0)
	LinesList.append (line)

	DisplayText()
	return 0

def DisplayText():

	temp = world.GetWorldWindowPosition.split(',')
	winHeight = int((int(temp[3]) - int(temp[1])) * 0.25)
	winWidth = int(temp[2]) - int(temp[0]) - 29

	world.WindowCreate (win, 0, 0, winWidth, winHeight, 4, 0, 0x000000)
	world.WindowRectOp (win, 2, 1, 1, -1, -1, 0x000000, 0x000000)

	for i in range(0, len(LinesList)):
		localTMargin = winTMargin + int(fontHeight)*i
		world.WindowText (win, 'body', LinesList[i], winLMargin, localTMargin, 0, 0, 0xCCCCCC, 1)

	world.WindowLine (win, 0, winHeight, winWidth, winHeight, 0xCCCCCC, 0, 5)

	world.WindowShow (win, 1)

]]>
</script>


</muclient>
Top

Posted by LupusFatalis   (154 posts)  Bio
Date Reply #17 on Sun 10 May 2009 07:47 AM (UTC)

Amended on Sun 10 May 2009 07:49 AM (UTC) by LupusFatalis

Message
I updated this version to include word wrapping. Huzzah!
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Friday, April 24, 2009, 7:01 PM -->
<!-- MuClient version 4.40 -->

<!-- Plugin "Most_Recent_Text" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Most_Recent_Text"
   id="5857d039eaa8c30c4c813ec8"
   language="Python"
   purpose="Miniwindow displaying up to date information while scrolling back the main window"
   date_written="2009-04-24 19:01:01"
   requires="4.40"
   version="1.0"
   >

</plugin>


<!--  Get our standard constants -->

<include name="constants.pys"/>

<!--  Script  -->


<script>
<![CDATA[

LinesList = []
winTMargin = 1
winLMargin = 1
win = world.GetPluginID
fontHeight = 16
wrapWidth = 107

def OnPluginDisconnect():
	world.WindowShow (win, 0)


def OnPluginClose():
	world.WindowShow (win, 0)


def OnPluginDisable():
	world.WindowShow (win, 0)


def OnPluginEnable():
	temp = world.GetWorldWindowPosition.split(',')
	winHeight = int((int(temp[3]) - int(temp[1])) * 0.25)
	winWidth = int(temp[2]) - int(temp[0]) - 29

	world.WindowCreate (win, 0, 0, winWidth, winHeight, 4, 0, 0x000000)
	world.WindowRectOp (win, 2, 1, 1, -1, -1, 0x000000, 0x000000)
	world.WindowLine (win, 0, winHeight, winWidth, winHeight, 0xCCCCCC, 0, 5)

	world.WindowShow (win, 1)


def OnPluginWorldOutputResized():
	temp = world.GetWorldWindowPosition.split(',')
	winHeight = int((int(temp[3]) - int(temp[1])) * 0.25)
	winWidth = int(temp[2]) - int(temp[0]) - 29

	world.WindowFont (win, 'body', 'Dina', 10, 0, 0, 0, 0, 1, 0)
	if not world.WindowFontInfo(win, 'body', 1):
		fontHeight = 16
	else:
		fontHeight = int(world.WindowFontInfo(win, 'body', 1))

	mLines = winHeight / fontHeight
	
	while len(LinesList) > mLines:
		LinesList.pop(0)

	DisplayText()
	
def OnPluginScreendraw(type, log, line):
	temp = world.GetWorldWindowPosition.split(',')
	winHeight = int((int(temp[3]) - int(temp[1])) * 0.25)
	winWidth = int(temp[2]) - int(temp[0]) - 29

	world.WindowFont (win, 'body', 'Dina', 10, 0, 0, 0, 0, 1, 0)
	if not world.WindowFontInfo(win, 'body', 1):
		fontHeight = 16
	else:
		fontHeight = int(world.WindowFontInfo(win, 'body', 1))

	mLines = winHeight / fontHeight

	nLine = line
	while len(nLine) > wrapWidth:
		sChar = nLine[0:wrapWidth].rfind(' ')
		aLine = str(nLine[0:sChar])

		if len(LinesList) >= mLines:
			LinesList.pop(0)
		LinesList.append (aLine)

		nLine = ' ' + nLine[sChar:len(nLine)].lstrip()

	if len(LinesList) >= mLines:
		LinesList.pop(0)
	LinesList.append (nLine)

	DisplayText()
	return 0

def DisplayText():

	temp = world.GetWorldWindowPosition.split(',')
	winHeight = int((int(temp[3]) - int(temp[1])) * 0.25)
	winWidth = int(temp[2]) - int(temp[0]) - 29

	world.WindowCreate (win, 0, 0, winWidth, winHeight, 4, 0, 0x000000)
	world.WindowRectOp (win, 2, 1, 1, -1, -1, 0x000000, 0x000000)

	for i in range(0, len(LinesList)):
		localTMargin = winTMargin + int(fontHeight)*i
		world.WindowText (win, 'body', LinesList[\i], winLMargin, localTMargin, 0, 0, 0xCCCCCC, 1)

	world.WindowLine (win, 0, winHeight, winWidth, winHeight, 0xCCCCCC, 0, 5)

	world.WindowShow (win, 1)

]]>
</script>


</muclient>
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


56,216 views.

This is page 2, subject is 2 pages long:  [Previous page]  1  2 

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.