|
Hi, I execute the following code and just get a blank (black) window. The window caption shows but I have not yet gotten the images to load. Please help. (I tried using other images than the ones utilized too). the .py and the images are in the same directory.
background_image_filename='checkmark.jpg'
mouse_image_filename='digestive_bw.png'
import pygame, sys
from pygame.locals import*
from sys import exit
pygame.init()
screen=pygame.display.set_mode((800,800),0,32)
#pygame.display.set_caption("Hello, Howdy, Mate, and Hi there Aus world!")
background=pygame.image.load(background_image_filename).convert()
mouse_cursor=pygame.image.load(mouse_image_filename).convert_alpha()
while True:
for event in pygame.event.get():
if event.type==QUIT:
pygame.quit()
sys.exit()
screen.blit(background,(0,0))
x,y=pygame.mouse.get_pos()
x-=mouse_cursor.get_width() /2
y=-mouse_cursor.get_height() /2
screen.blit(mouse_cursor,(x,y))
pygame.display.update()
|
|
|
|
|
I am using an ActiveX which is refered using <object> tag in my JavaScript code. This javascript is used in a Java based web application. When user browse this page first time, my ActiveX get downloaded from server and installed on client machine. I want to show a progress bar when IE downloading ActiveX. Please suggest what apporach I can use to implement this.
Manish Agarwal
manish.k.agarwal @ gmail DOT com
|
|
|
|
|
The unfortunate thing is that you can't do a true progress bar, because you don't have access to the count of downloaded bytes. What most sites do is to display an animated gif image that acts as a placebo. It makes people feel like something is happening, but gives no true measure of it.
|
|
|
|
|
Thanks for your reply. I was also thinking to do same but looking for somekind of notification when object is fully downloaded and I have to stop the animation.
Manish Agarwal
manish.k.agarwal @ gmail DOT com
|
|
|
|
|
readyState
==========
Retrieves the current state of the object.
Syntax
Scripting [ vState = ] object.readyState
Possible Values
vState Variant that receives one of the following values.uninitialized Object is not initialized with data.
loading Object is loading its data.
loaded Object has finished loading its data.
interactive User can interact with the object even though it is not fully loaded.
complete Object is completely initialized.
The property is read-only. The property has no default value.
Remarks
The states through which an object passes are determined by that object; an object can skip certain states
(for example, interactive) if those states do not apply to that object.
Standards Information
There is no public standard that applies to this property.
Applies To
A, ACRONYM, ADDRESS, APPLET, AREA, B, BASE, BASEFONT, BDO, BGSOUND, BIG, BLOCKQUOTE, BODY, BR, BUTTON,
CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, CUSTOM, DD, DEL, DFN, DIR, DIV, DL, DT, EM, EMBED,
FIELDSET, FONT, FORM, FRAMESET, HEAD, hn, HR, HTML, I, IFRAME, INS, ISINDEX, KBD, LABEL, LEGEND, LI,
LISTING, MAP, MARQUEE, MENU, namespace, nextID, NOBR, NOFRAMES, NOSCRIPT, OL, OPTION, P, PLAINTEXT,
PRE, Q, RT, RUBY, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TEXTAREA, TITLE, TT, U, UL, VAR, XML, XMP
----------------------------------------------------------
[ nState = ] XMLHttpRequest.readyState
Possible Values
nState Integer that receives one of the following values.0 The object has been created, but not initialized (the open method has not been called).
1 The object has been created, but the send method has not been called.
2 The send method has been called, but the status and headers are not yet available.
3 Some data has been received. Calling the responseBody and responseText properties at this state to obtain
partial results will return an error, because status and response headers are not fully available.
4 All the data has been received, and the complete data is available.
The property is read-only. The property has no default value.
Applies To
XMLHttpRequest
|
|
|
|
|
My js looks like as
function fnLoadMyo()
{
window.status="Myo Loading..";
var s = <object classid="clsid:A6S60BCD-BC5E-4088-EFCE-B9EED1D84CB3" id="myo" height="100%" width="100%/">';
document.getElementById('myoSection').innerHTML = s;
alert(myo.readyState);
}
In above alert, I always get 4, irrespective of activex downloaded or registered on client or not.
Manish Agarwal
manish.k.agarwal @ gmail DOT com
|
|
|
|
|
create an activeX object
don't forget
'OBJECT ID="' ... + '"'
+ ' CLASSID="' .... + '"'
+ ' TYPE="' .... + '"'
....
e.g.
"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"; Mediaplayer Class-ID
"application/x-oleobject" type of Class-ID and media
-----------------------------------
create object directly, not with innerHTML.
X12=document.createElement(....);
X13=document.body.appendChild(X12);
try
{
X13.classid=....
X13.type=....
}
catch(e)
{
...
}
or
X12=document.createElement("<object id="..." classid="..."">); // e.g IE
X13=document.body.appendChild(X12);
after that maybe readystate is 4, but
pointer X13 must be !=null and !=undefined
X13.property too e.g. X14.classid
at this point activex exists (installed an callable)
e.g. Mediapalyer and try ..catch
// - - - check MediaPlayer createable, only IE
function checkMediaPlayer()
{
var X00=false;
var X01;
// ----- only if IE exist
// ----- create
X01=document.createElement("OBJECT");
// X01 mus be !=null and !=undefinded
// ----- set object try-catch so no place for readystate
try
{
// attention: activex must be allowed by user
// maybe NOT possible
// X01.classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95";
// X01.type="application/x-oleobject";
// X01.filename= ..... // dummy-wmv 1 sec must exists !
// maybe only that possible
X01.type="application/x-mplayer2"; // EMBED and not activeX
X01.filename= ..... // dummy-wmv 1 sec must exist !
}
catch(e1)
{X00=false;}
// ----- no append to body so no remove from body
if(X00)
{
try{X01.filename='';}
catch(e3){X00=false;}
}
// ----- clear object
X01=null; // no append to body so no remove from body
return X00;
}
|
|
|
|
|
how i do check the checkbox on tablerow by clicking datarow.for example in xampp phpmyadmin
اسلام پیروز است
|
|
|
|
|
You should have a look at line 522 of functions.js
If you right-click a table-row with Chrome or Opera, you can then select Inspect Element.
This will open the Dev Tools console. with the table-row still selected, you can then open the Event Listeners entry in the accordian. When I did this, I saw that the code for handling mouse-clicks on table-rows was to be found on line 522 of functions.js
With that done, one can see that the function basically looks for all any child elements of the row of type 'input' it then does some logic checking before checking/unchecking the checkbox.
Here's the function for reference. (I've marked what was line 522 with *****)
var marked_row = new Array;
function PMA_markRowsInit() {
var rows = document.getElementsByTagName('tr');
for ( var i = 0; i < rows.length; i++ ) {
if ( 'odd' != rows[i].className.substr(0,3) && 'even' != rows[i].className.substr(0,4) ) {
continue;
}
if ( navigator.appName == 'Microsoft Internet Explorer' ) {
rows[i].onmouseover = function() {
this.className += ' hover';
}
rows[i].onmouseout = function() {
this.className = this.className.replace( ' hover', '' );
}
}
if (rows[i].className.search(/noclick/) != -1) {
continue;
}
rows[i].onmousedown = function() {
var unique_id;
var checkbox;
checkbox = this.getElementsByTagName( 'input' )[0];
if ( checkbox && checkbox.type == 'checkbox' ) {
unique_id = checkbox.name + checkbox.value;
} else if ( this.id.length > 0 ) {
unique_id = this.id;
} else {
return;
}
if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
marked_row[unique_id] = true;
} else {
marked_row[unique_id] = false;
}
if ( marked_row[unique_id] ) {
this.className += ' marked';
} else {
this.className = this.className.replace(' marked', '');
}
if ( checkbox && checkbox.disabled == false ) {
checkbox.checked = marked_row[unique_id];
}
}
var labeltag = rows[i].getElementsByTagName('label')[0];
if ( labeltag ) {
labeltag.onclick = function() {
return false;
}
}
var checkbox = rows[i].getElementsByTagName('input')[0];
if ( checkbox ) {
checkbox.onclick = function() {
this.checked = ! this.checked;
}
}
}
}
window.onload=PMA_markRowsInit;
Make it work. Then do it better - Andrei Straut
|
|
|
|
|
Thanks enhzflep !
But How i do it with PHP
اسلام پیروزاست.اسلامنا غالب
|
|
|
|
|
You're welcome.
Well, you can't do it with PHP. That is to say, PHP is only good for performing calculations before outputting to a web-browser.
You can't do it with the keyboard, since the keyboard just allows you to create the page that is then displayed. Well, for the purpose of this discussion, PHP works just like the keyboard, except a little faster.
So, where does that leave you if you want to create a page with PHP and have it behave in the same way?
Well, you simply put the appropriate javascript into a js file. You then link that file to the html output, with a
<script src='......'></script> tag.
You can see from the last line of the code I posted, that the onload function for the document calls a function which attaches an event handler to each of the table-rows in the page.
So, you could put the function into the javascript file.
You can link that file to the output of the PHP
You can call the function either with <body onload='yourInitFunc();'> in the html
or with window.onload = yourInitFunc; in the javascript.
Presumably, you're assembling the page in PHP perl-style, I.e you're using print, printf or echo to output each line of content as you go. In that case, you just output the required tags with a print statement at the appropriate place.
If on the other hand, you're using DOM objects to construct the page - then you'll need to create the script node & set it's src attribute to point to the javascript file.
To be perfectly honest, if I was in your shoes then I'd just make a quick html file that did nothing but try to attach a function to the onclick event of each of the table rows.
Okay, I got bored - have a play around with this. Make it work the way you'd like, then output the file dynamically, instead of with the keyboard (or in your case, copy/paste)
<!doctype html>
<html>
<head>
<script>
function myRowClickFunction()
{
alert('row clicked');
}
function myBtnClicked()
{
alert('btn clicked');
}
function addBtnToRow()
{
td = document.createElement('td');
btnInput = document.createElement('input');
btnInput.setAttribute('value', 'click me');
btnInput.setAttribute('type', 'button');
btnInput.onclick = myBtnClicked;
td.appendChild(btnInput);
this.appendChild(td);
this.onclick = null;
}
function attachEventHandlerToTableRows(functionToAttach)
{
var i, num;
var tableRows = document.getElementsByTagName('tr');
num = tableRows.length;
for (i=0; i<num; i++)
{
tableRows[i].onclick = functionToAttach;
}
}
function myInit()
{
attachEventHandlerToTableRows(myRowClickFunction);
}
</script>
</head>
<body onload='myInit();'>
<table>
<tbody>
<tr><td>This is row 1</td></tr>
<tr><td>This is row 2</td></tr>
<tr><td>This is row 3</td></tr>
<tr><td>This is row 4</td></tr>
<tr><td>This is row 5</td></tr>
</tbody>
</table>
</body>
</html>
Make it work. Then do it better - Andrei Straut
|
|
|
|
|
OKAY my friend!!!
but how i get the row index and if i give a checkbox on first td how i change the checkbox state on tr click ?
i create checkboxes dynamically on webpage with php .
HELP ME!!!!
اسلام پیروزاست.اسلامنا غالب
|
|
|
|
|
If you need the row index, it's a good idea to stash it in the element, e.g.
<table>
<tr><th>... (header row)</tr>
<tr rowid=0><td>... </tr>
<tr rowid=1><td>... </tr>
</table>
(I'm not sure if you can use tBodies[0].rows.indexOf or something like that. I'm not an expert in this regard. But what you usually want is actually a row id which can be tied into the query you are running, and that won't be the same as the index anyway.)
If you know the checkbox is in the same row, though, you don't need the index to adjust it.
function rowOnClickHandler(evt){
var row = evt.target ? evt.target : evt.srcElement;
var checkbox = row.cells[0].getElementsByTagName('INPUT')[0];
checkbox.selected = !checkbox.selected;
}
|
|
|
|
|
Good answer. +5
Make it work. Then do it better - Andrei Straut
|
|
|
|
|
Just like Bob said, the easiest/quickest way to get the index of the clicked row (in case you need the number for something else) is to add an attribute to the TR elements - you can then query this value in your onclick handler.
Drawing on the code I wrote earlier, here's a dynamic solution.
------------------ tblTest.php ----------------------
<!doctype html>
<html>
<head>
<script>
function myRowClickFunction()
{
alert('row clicked');
}
function myBtnClicked()
{
alert('btn clicked');
}
function rowClickedToggleCheckBox()
{
var clickedRow = this;
var checkBox = clickedRow.getElementsByTagName('input')[0];
checkBox.checked = (!checkBox.checked);
alert('Index of clicked row: ' + clickedRow.getAttribute('rowIndex'));
}
function addBtnToRow()
{
td = document.createElement('td');
btnInput = document.createElement('input');
btnInput.setAttribute('value', 'click me');
btnInput.setAttribute('type', 'button');
btnInput.onclick = myBtnClicked;
td.appendChild(btnInput);
this.appendChild(td);
this.onclick = null;
}
function attachEventHandlerToTableRows(functionToAttach)
{
var i, num;
var tableRows = document.getElementsByTagName('tr');
num = tableRows.length;
for (i=0; i<num; i++)
{
tableRows[i].onclick = functionToAttach;
}
}
function myInit()
{
attachEventHandlerToTableRows(rowClickedToggleCheckBox);
}
</script>
</head>
<body onload='myInit();'>
<table>
<tbody>
<?php
for ($i=0; $i<10; $i++)
{
echo "<tr rowIndex='$i'><td><input type='checkbox' id='cb_$i'></td><td>click to toggle checkBox</td></tr>";
}
?>
</tbody>
</table>
</body>
</html>
Make it work. Then do it better - Andrei Straut
|
|
|
|
|
Beautiful! I can think of many places where this would be useful. Bravo on your explanation and great example! Clean, concise, and well documented. I don't usually get to do too much web development, but just spent a week immersed in it adding features to a legacy ASP application. It never fails to amaze me how much can be handled on the clent side. I think you might only be limited by your imagination.
"Go forth into the source" - Neal Morse
|
|
|
|
|
Hi, I want to make ref of jquery.js through c# code and then want to create a function in C# to which i want to pass object as parameter. That function will do tasks that JQuery do. f.g Button as object and do animations on button using Jquery with C#(function). Thanks in advance.
|
|
|
|
|
I don't quite understand what you want to do.
1. Reference jquery in your webform
2. Create a function in code behind
3. code behind function passes parameters to a jquery script
4. Jquery then runs the parameters
I think you need to change your thinking on this.
Jquery can go to the server to get parameters.
Code Behind can prepare parameters on page load, then jquery can read them.
Something has to trigger a jquery function.
jquery is essentially javascript, just a little easier to pick up at first.
You really need to get started first, and learn how to use javascript before you dive into jquery, start below.
http://jquery.com/[jquery^]
|
|
|
|
|
Hi, I am an intermediate user with JQuery.
Actually I want to create a class in c# that will handle Jquery functionality.
My purpose regarding this is :
1> If someone dont know jquery then one can use my C# funtions for animation or other tasks that jquery has. My class will call jquery functions and ll return output.
2> Easy to debug the code using vs-degugger.
|
|
|
|
|
I write server control dll's, in which I embed scripts, and load the appropriate ones on demand, during the page.init life cycle. And then I create controls, that wire up to the scripts. When the page loads, everything is functional.
If you just had a pin-point question, with a code sample, then that's easy to answer, but in your case, your looking for someone to engineer it for you, and I don't think a class is sufficient for your needs.
I don't have an answer to offer, because I think the concept is flawed, or it exist on a super advanced level of programming.
|
|
|
|
|
I don't think you understand how ASP.net works. This isn't entirely your fault because ASP.net does its best to hide the client/server nature of websites.
Back end (C#) code is executed on the server. Its purpose is to generate markup which is sent to the browser, which can include scripts and links to scripts (e.g. jQuery). Once a request has been handled and markup sent back to the browser, your back end code is not running any more.
jQuery (like other JavaScript code) is run in the browser, and allows you to modify what the client sees or does. Anything interactive that happens in the browser is done with JS.
The only ways to communicate between them are HTTP requests, either through loading a new page with an <a> or <form action=...> tag, or via an AJAX request.
Animation is a client side task and therefore it will always be done with JavaScript. There is simply no (sane) way to get back end code involved in that code cycle, because the animation is done in the browser and the server is not involved.
|
|
|
|
|
That's a good explanation you wrote there Bob.
I guess he wants to write a class in which if you want to animate an object, you just call his class and the object, and he does the rest.
I don't think just a class is big enough for that, so he's needs some serious engineering there on how to build it.
You and I could actually write something like that, but I don't have a need for that at this moment in time.
But I have my thinking cap on now, and if I needed it today, I would attempt to write a jquery plugin, that you just attach to the object, to call the simple animations needed by the user.
So that's the answer, write a jquery plugin then. I forget the OP's Name, so OP, I'd leave the asp.net out of this, and look into writing a plugin.
Here's a link with some sample code to get you started today!
http://docs.jquery.com/Plugins/Authoring[^]
|
|
|
|
|
I am building a project managent information system and I need a texteditor in some of my pages. How do i go about having it work in my application.
|
|
|
|
|
First you find one that fits your purposes, then you download it and add any components/JavaScript references/CSS files that it needs. Finally, you add it to your page and call any initialisation routines.
That's as specific as I can get right now. The editor you include should have samples and documentation that show how to add it into your site.
|
|
|
|
|
<textarea>
|
|
|
|
|