I'm trying to display (enabled) a combobox based on a particular item selected in a previous combobox. I have attempted many combinations, and can't seem to get it to behave properly. It will display normally (disabled), but I want it only to display (enabled) when a certain item is selected. I've tried .Refresh() and EVT_COMBOBOX, and they do not work. Below is the code in question:
#Media Quality
self.formats3 = ['-sameq','-qmax']
self.format_combo3=wx.ComboBox(self, size=(100, -1),value='Select Quality', choices=self.formats3, style=wx.CB_DROPDOWN, pos=(300,141))
quality=self.format_combo3.GetValue()
#-qmax settings
self.formats4 = ['1','2','3','4','5','6','7','8']
self.format_combo4=wx.ComboBox(self, size=(30, -1),value='0', choices=self.formats4, style=wx.CB_DROPDOWN, pos=(405,141))
self.format_combo4.Disable()
if quality == '-qmax':
self.format_combo4.Enable()
else:
self.format_combo4.Disable()
Solution:
#-qmax settings
self.formats4 = ['1','2','3','4','5','6','7','8']
self.format_combo4=wx.ComboBox(panel, size=(30, -1),value='0', choices=self.formats4, style=wx.CB_DROPDOWN, pos=(405,111))
self.format_combo4.Disable()
#Media Quality
self.formats5 = ['Select Preset','video to mp3']
self.format_combo5=wx.ComboBox(panel, size=(100, -1),value='Select Preset', choices=self.formats5, style=wx.CB_DROPDOWN, pos=(300,141))
#Bit rate
self.formats6 = ['k/bs','128000', '160000', '180000', '192000']
self.format_combo6=wx.ComboBox(panel, size=(47, -1),value='k/bs', choices=self.formats6, style=wx.CB_DROPDOWN, pos=(405,141))
self.format_combo6.Disable()
def OncomboBox(self, e):
quality=self.format_combo3.GetValue()
if quality == '-qmax':
self.format_combo4.Enable()
else:
self.format_combo4.Disable()
Related
How to draw a border to highlight a SCNNode and indicate to user that the node is selected?
In my project user can place multiple virtual objects and user can select any object anytime. Upon selection i should show the user highlighted 3D object. Is there a way to directly achieve this or draw a border over SCNNode?
You need to add a tap gesture recognizer to the sceneView.
// add a tap gesture recognizer
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap(_:)))
scnView.addGestureRecognizer(tapGesture)
Then, handle the tap and highlight the node:
#objc
func handleTap(_ gestureRecognize: UIGestureRecognizer) {
// retrieve the SCNView
let scnView = self.view as! SCNView
// check what nodes are tapped
let p = gestureRecognize.location(in: scnView)
let hitResults = scnView.hitTest(p, options: [:])
// check that we clicked on at least one object
if hitResults.count > 0 {
// retrieved the first clicked object
let result = hitResults[0]
// get its material
let material = result.node.geometry!.firstMaterial!
// highlight it
SCNTransaction.begin()
SCNTransaction.animationDuration = 0.5
// on completion - unhighlight
SCNTransaction.completionBlock = {
SCNTransaction.begin()
SCNTransaction.animationDuration = 0.5
material.emission.contents = UIColor.black
SCNTransaction.commit()
}
material.emission.contents = UIColor.red
SCNTransaction.commit()
}
}
The snippet above highlights the whole node. You'd have to adjust it to highlight the borders only, if that's what you're looking for.
Disclaimer:
This code was taken directly from Xcode's template code created when opening a new game (SceneKit) project.
For my Angular JS grid work, I'm using ui-grid rather than ng-grid as ui-grid is meant to be the new version which is purer Angular.
I've got a grid that I'm populating with a http response, and I'm able to select a row (based on finding the record matching a $scope variable value) using the api.selection.selectRow method call.
What I need to do next is scroll the grid to that record.
There's an existing stack overflow question along the same lines that is for ng-grid and the answer to that refers to undocumented features which are not present in ui-grid so I can't use that approach.
The closest I've got is finding $scope.gridApi.grid to get a reference to the actual grid itself but looking through the properties and methods in the Chrome debugger doesn't show anything that sounds like it could work.
You can use the cellNav plugin. You should already have a reference to your row entity from the selection. The documentation is here.
gridApi.cellNav.scrollTo(grid, $scope, rowEntity, null);
I managed to hack together something that works pretty well but it's a bit dodgy and could probably be cleaner with a bit more Angular/jquery understanding.
I used the browser dom explorer to find that the scrollbars have a css class that we can detect to find them and then set the scroll properties on them to have the grid scroll (the grid and scrollbars are separate divs but their properties are bound so changing one updates the other).
It doesn't completely work for scrolling to the last row of the grid. This could be a timing issue, I've noticed when using breakpoints that the grid comes on screen a little larger and then shrinks down to it's final size. This could be messing with the scrolling values.
The first loop finds the height of the grid by adding up the rows, and the y position of the row for my data object (project), then we find the scrollbar and set it's scrollTop, trying to centre the row on screen without going out of bounds.
var grid = $scope.projectsGridApi.grid;
// var row = grid.rowHashMap.get(project.$$hashKey);
var found = false;
var y = 0;
var totalY = 0;
var rowHeight = 0;
for (var rowIdx in grid.rows)
{
var row = grid.rows[rowIdx];
if (row.entity.$$hashKey == project.$$hashKey)
{
found = true;
rowHeight = row.height;
}
if (!found)
{
y += row.height;
}
totalY += row.height;
}
// now find the scroll bar div and set it's scroll-top
// (todo: checking if we're at the end of the list - setting scrollTop > max means it doesn't work properly
var grid = $scope.projectsGridApi.grid;
// annoyingly this is nastily coded to find the scrollbar and isn't completely right
// I think the grid is a little taller when this is called, then shrinks
// which affects what the maximum is (so we might not always be able to put the selected item on screen if it is the last one).
var holderDiv = $('#projectsGridHolder');
if (holderDiv)
{
var scrollBarDivs = holderDiv.find('.ui-grid-native-scrollbar');
if (scrollBarDivs)
{
for (var scrollBarDivIdx in scrollBarDivs)
{
var scrollBarDiv = scrollBarDivs[scrollBarDivIdx];
var scrollBarDivClass = scrollBarDiv.className;
if (scrollBarDivClass)
{
if (scrollBarDivClass.indexOf('vertical') != -1)
{
var scrollHeight = scrollBarDiv.scrollHeight;
var clientHeight = scrollBarDiv.clientHeight;
if (rowHeight > 0)
{
y -= (clientHeight - rowHeight) / 2; // center on screen be scrolling slightly higher up
}
if (y < 0) y = 0;
else if (y > totalY - clientHeight) y = totalY - clientHeight;
scrollBarDiv.scrollTop = y;
}
}
}
}
}
In DevExpress XtraCharts for WinForms, is there a way to have the Y Axis adjust automatically as a user scrolls left and right through the data (so that the data that is currently displayed on the screen fills most of the chart)?
If not automatically are there any demos or would someone have any pointers on how to do this?
You can see this effect happening on this video as the user scrolls left and right the Y-Axis changes: https://www.youtube.com/watch?v=HmA6vANrKKk
According to DevExpress tech support, you have to do it yourself:
"It is necessary to calculate and set Axis Y range manually as described in the Auto adjust Y-Axis range when scrolling on zooming on X-Axis thread. Please try this solution and let me know if you need an additional assistance with this solution implementation."
I also had to add the following statement to get the Y-Axis changes to show up:
stockView.AxisY.VisualRange.SideMarginsValue = 0
Just set the Axis.VisualRange.Auto property to true to specify that the minimum and maximum axis values are calculated automatically based upon the series being drawn.
Maybe this helps some. The following code solves 2 issues: a) updating of yAxis on main ChartControl when zooming or scrooling, and b) updating the same when adjusting the range on an associated RangeControl.
I use a RangeControl in addition to my ChartControl and strangely the event RangeChanged of RangeControl is raised even when you zoom or scroll on the main chart. This should not be and stanger even the opposite does not hold true: When changing the range of RangeControl none of the events of ChartControl are raised. What complicates things even further is RangeChanged of RangeControl runs on a background thread.
private void RangeControlOnRangeChanged(object sender, RangeControlRangeEventArgs range)
{
var measureUnit = ((XYDiagram)chartControl.Diagram).AxisX.DateTimeScaleOptions.MeasureUnit;
var origin = default(DateTime);
DateTime minDt, maxDt;
switch (measureUnit)
{
case DateTimeMeasureUnit.Millisecond:
minDt = origin.AddMilliseconds((double) range.Range.Minimum);
maxDt = origin.AddMilliseconds((double) range.Range.Maximum);
break;
case DateTimeMeasureUnit.Second:
minDt = origin.AddSeconds((double) range.Range.Minimum);
maxDt = origin.AddSeconds((double) range.Range.Maximum);
break;
case DateTimeMeasureUnit.Minute:
minDt = origin.AddMinutes((double) range.Range.Minimum);
maxDt = origin.AddMinutes((double) range.Range.Maximum);
break;
case DateTimeMeasureUnit.Hour:
minDt = origin.AddHours((double) range.Range.Minimum);
maxDt = origin.AddHours((double) range.Range.Maximum);
break;
case DateTimeMeasureUnit.Day:
minDt = origin.AddDays((double) range.Range.Minimum);
maxDt = origin.AddDays((double) range.Range.Maximum);
break;
case DateTimeMeasureUnit.Year:
minDt = origin.AddYears((int)(double) range.Range.Minimum);
maxDt = origin.AddYears((int)(double) range.Range.Maximum);
break;
default:
throw new NotImplementedException();
}
var visibleDataPoints = DataSeries.Where(x => x.TimeStamp >= minDt && x.TimeStamp <= maxDt);
var newMinValue = visibleDataPoints.Min(x => x.Value);
var newMaxValue = visibleDataPoints.Max(x => x.Value);
chartControl.BeginInvoke(new Action(() => ((XYDiagram)chartControl.Diagram).AxisY.VisualRange.SetMinMaxValues(newMinValue, newMaxValue)));
}
Note that DataSeries here is a collection that implements IList, where DataPoint is struct that holds a DateTime time stamp and a value of type double. But the binding can be done in a myriads of ways. Also note that here you don't even need to hook up Scroll or Zoom events because of the above mentioned oddity in that the RangeChanged event of RangeControl is raised when you scroll or zoom.
I find some of the design and some lacking core features of the DevExpress WinForms charting library extremely embarrassing, given they allow for the most detailed little items to be adjusted while some hugely important features are missing and/or still have not been fixed/added years after they were brought up by users. Maybe I am the only one to complain but I felt it should be voiced.
Try below codeļ¼
diagram.DependentAxesYRange = DefaultBoolean.True;
diagram.AxisY.WholeRange.AlwaysShowZeroLevel = false;
I am working with XamDataGrid where in i have to disable the Row:0 Cell:1 enabled all the times.
to achieve this i Set AllowEdit for the field to false and then dynamically onClick of the cell for selection: i am trying to get rowindex and cell index and see if they are for first row i set enable. But that enables entire column all rows which i dont want.
DataRecord selectedRecord = (DataRecord)frameSpacingDataGrid.ActiveRecord;
Cell selectedCell = frameSpacingDataGrid.ActiveCell;
CellCollection cellCollection = selectedRecord.Cells;
int indxSelectedCell = cellCollection.IndexOf(selectedCell);
var rowIndex = selectedRecord.Index;
if (rowIndex == 0 && indxSelectedCell == 0)
{
selectedCell.DataPresenter.IsEnabled= true;
}
Above code is written in SelectedItemsChanged event.
Also, when user deletes rows: new row:0 and cell:0 should be editable.
How do i achieve this Via Triggers/XAML/ Codebehind.
I have found a work around as stated here:
What i did is to set cancel for the edit event.
But surely this is not a proper solution.
I have a DataGrid bound to a matrix.
The main logic of the application is that any cell having a value of 0 will just display nothing (0 = no value in my referential).
Now what I want is that, when the user presses the Delete button, all the cells selected will be set to 0.
I can easily do that with one cell (because I keep track of the current row/column selected), but I can't get, let's say, a 2x2 square correctly.
The best way I figured out, using Binding magic, would be to get the row/column indexes of each cell selected, and then set the Binding's source to 0. But still, I can't have all of the row numbers (basically because grid.SelectedCells is an IEnumerable<DataGridCellInfo>, and I can only get the column with this object, I have no way to get the current row.)
It works when I only select one cell(or one row), by using the following:
DataGridRow dataGridRow = (DataGridRow)this.ItemContainerGenerator.ContainerFromItem(grid.CurrentItem);
How about multiple selection?
Any ideas here? Thanks!
Try this to get to the selected cells value:
DataGridCellInfo cell = dataGrid1.SelectedCells[0];
((TextBlock) cell.Column.GetCellContent(cell.Item)).Text = "";
Counting that the cells are textblocks.
foreach (DataGridCellInfo cellInfo in grid.SelectedCells)
{
DataGridColumn column = cellInfo.Column;
string propertyName = ((Binding)column.ClipboardContentBinding).Path.Path;
PropertyInfo pi = cellInfo.Item.GetType().GetProperty(propertyName);
if (pi != null)
{
pi.SetValue(cellInfo.Item, null, null);
}
}
ICollectionView cv = CollectionViewSource.GetDefaultView(grid.Items);
cv.Refresh();